Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stats = game:GetService("DataStoreService"):GetDataStore("Stats")
- houseOffset = 1
- GroupTime = 300 --Time it takes to get 500 Veza by being in group
- math.randomseed(tick())
- --------VEZA SPAWNING
- ChancesOfFindingVeza = 2/3 --Percent of locations that will have vezas
- ChancesOfGettingRare = 35 --Percent of getting the gold rare vize [Currently 35%]
- RegenTime = 300 --Amount of seconds the veza spawns
- --------VEZA SPAWNING
- game.Players.PlayerAdded:connect(function(p)
- coroutine.resume(coroutine.create(function()
- p:WaitForChild("Backpack")
- local event333 = Instance.new("RemoteEvent")
- event333.Parent = p.Backpack
- event333.Name = "ShowFearRewards"
- repeat wait() until p.Character ~= nil
- wait(3)
- event333:FireClient(p)
- end))
- local stats = game:GetService("DataStoreService"):GetDataStore("Stats")
- local config = script.Config:Clone()
- if p:IsInGroup(72321) then
- local asdf = Instance.new("IntValue",p)-----------------
- asdf.Name = "GroupTimer"-----------------
- asdf.Value = GroupTime------------------------------------------------
- coroutine.resume(coroutine.create(function()
- while wait() do
- for i=asdf.Value,0,-1 do
- asdf.Value = i
- wait(1)
- end
- p.Config.Veza.Value = p.Config.Veza.Value + 750
- asdf.Value = GroupTime
- end
- end))
- end
- config.Parent = p
- p:WaitForDataReady()
- local data = stats:GetAsync(p.userId)--Loading
- config.House.Changed:connect(function()
- game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
- local house = Workspace.Houses:FindFirstChild(p.Name.."'s house")
- if house ~= nil then
- house:Destroy()
- end
- if config.House.Value ~= 0 then
- local house = nil
- if config.House.Value == 1 then
- house = game.ReplicatedStorage.ValenciaCondos:Clone()
- elseif config.House.Value == 2 then
- house = game.ReplicatedStorage.HouseName:Clone()
- end
- house.Name = p.Name.."'s house"
- house.Parent = Workspace.Houses
- house:TranslateBy(Vector3.new(0,houseOffset*100,0))
- houseOffset = houseOffset + 1
- repeat wait() until config:FindFirstChild("Base") ~= nil
- if config:FindFirstChild("Base") ~= nil then
- for i,v in pairs(config:GetChildren()) do
- local data23 = {}
- pcall(function()
- for ii in string.gmatch(v.Value, "%D+") do
- table.insert(data23,ii)
- end
- end)
- if string.sub(v.Name,1,4) == "Base" and house:FindFirstChild(v.Name) ~= nil then
- house:FindFirstChild(v.Name).BrickColor = BrickColor.new(data23[1])
- house:FindFirstChild(v.Name).Material = Enum.Material[tostring(data23[2])]
- end
- v.Changed:connect(function()
- if string.sub(v.Name,1,4) == "Base" and house:FindFirstChild(v.Name) ~= nil then
- house:FindFirstChild(v.Name).BrickColor = BrickColor.new(data23[1])
- house:FindFirstChild(v.Name).Material = Enum.Material[tostring(data23[2])]
- end
- end)
- end
- end
- end
- end)
- if data ~= nil then
- for i,v in pairs(data) do
- local cloneIt = false
- for a,b in pairs(script.Config:GetChildren()) do
- if b.Name == i then
- cloneIt = true
- end
- end
- if cloneIt == true then
- config[i].Value = v
- end
- end
- if Workspace.Houses:FindFirstChild(p.Name.."'s house") ~= nil then
- local house = Workspace.Houses:FindFirstChild(p.Name.."'s house")
- for i,v in pairs(data) do
- local cloneIt = false
- for a,b in pairs(script.Config:GetChildren()) do
- if b.Name == i then
- cloneIt = true
- end
- end
- if cloneIt == false then
- local data2 = {}
- for ii in string.gmatch(v, "%S+") do
- table.insert(data2,ii)
- end
- local name = ""
- for ii in string.gmatch(i, "%D+") do name = ii end
- local obj = game.ReplicatedStorage.Furniture[name]:Clone()
- obj.Parent = house
- obj.Name = i
- obj:TranslateBy((Vector3.new(tonumber(string.sub(data2[1],1,string.len(data2[1])-1)),tonumber(string.sub(data2[2],1,string.len(data2[2])-1)),tonumber(string.sub(data2[3],1,string.len(data2[3])-1)))+house.Base.Position)-obj:GetModelCFrame().p)
- --print(house.Base.Position,obj:GetModelCFrame().p)
- for ii,vv in pairs(obj:GetChildren()) do
- if not vv:IsA("IntValue") and not vv:IsA("StringValue") then
- vv.CFrame = (obj:GetModelCFrame()*CFrame.Angles(0,tonumber(data2[4]),0)):toWorldSpace(obj:GetModelCFrame():toObjectSpace(vv.CFrame))
- end
- end
- local save = Instance.new("StringValue")
- save.Value = tostring(obj:GetModelCFrame().p-house.Base.Position)..", "..data2[4]--tostring(obj:GetModelCFrame().p)..", "..data2[4]
- save.Name = i
- save.Parent = config
- end
- end
- end
- end
- end)
- Workspace.Houses.ChildAdded:connect(function(child)
- wait()
- game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
- child:WaitForChild("Locked").Changed:connect(function()
- wait()
- game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
- end)
- end)
- Workspace.Houses.ChildRemoved:connect(function()
- wait()
- game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
- end)
- game.Players.PlayerRemoving:connect(function(p)
- local Data={}
- for i,v in pairs(p.Config:GetChildren()) do--Saving
- Data[v.Name] = v.Value
- end
- local house = Workspace.Houses:FindFirstChild(p.Name.."'s house")
- if house ~= nil then
- house:Destroy()
- end
- stats:SetAsync(p.userId, Data)
- wait(1)
- game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
- end)
- game.OnClose = function()
- wait(3)
- end
- local event = Instance.new("RemoteFunction")
- event.Parent = Workspace
- event.Name = "ChangeValue"
- function event.OnServerInvoke(plr,name,newVal)
- plr.Config[name].Value = newVal
- return ""
- end
- local event38 = Instance.new("RemoteEvent")
- event38.Parent = Workspace
- event38.Name = "Destroyer"
- event38.OnServerEvent:connect(function(plr,obj)
- obj:Destroy()
- end)
- local event3 = Instance.new("RemoteEvent")
- event3.Parent = Workspace
- event3.Name = "AddFurniture"
- event3.OnServerEvent:connect(function(plr,house,furniture,pos,rotation)
- local obj = furniture:Clone()
- obj.Parent = house
- obj:TranslateBy(pos-obj:GetModelCFrame().p)
- for i,v in pairs(obj:GetChildren()) do
- if not v:IsA("IntValue") or v:IsA("StringValue") then
- v.CFrame = (obj:GetModelCFrame()*CFrame.Angles(0,rotation,0)):toWorldSpace(obj:GetModelCFrame():toObjectSpace(v.CFrame))
- end
- end
- local count = 1
- for i, v in pairs(plr.Config:GetChildren()) do
- if furniture.Name:find(v.Name:match("%D+")) and v.Name:match("%d+") then
- if count < tonumber(v.Name:match("%d+")) then
- count = tonumber(v.Name:match("%d+"))
- end
- end
- end
- count = count + 1
- local save = Instance.new("StringValue")
- save.Value = tostring(obj:GetModelCFrame().p-house.Base.Position)..", "..rotation
- save.Name = furniture.Name..count
- obj.Name = furniture.Name..count
- save.Parent = plr.Config
- end)
- local event2 = Instance.new("RemoteFunction")
- event2.Parent = Workspace
- event2.Name = "LockHouse"
- function event2.OnServerInvoke(plr,house)
- house.Locked.Value = not house.Locked.Value
- return house.Locked.Value
- end
- function SpawnVeza()
- Workspace.Vezas:ClearAllChildren()
- local PossibleLocations = {}
- for i,v in pairs(Workspace.VezaSpawns:GetChildren()) do
- table.insert(PossibleLocations,v)
- end
- local Num = math.floor(#PossibleLocations*ChancesOfFindingVeza)
- for i=1, Num do
- local pos = math.random(1,#PossibleLocations)
- local chosen = PossibleLocations[pos]
- local veza = nil
- if math.random(1,100) <= ChancesOfGettingRare then
- veza = game.ReplicatedStorage.Veza["Gold Rare Veza"]:Clone()
- else
- veza = game.ReplicatedStorage.Veza["Normal Veza"]:Clone()
- end
- veza.Parent = Workspace.Vezas
- veza.CFrame = chosen.CFrame
- table.remove(PossibleLocations, pos)
- end
- return
- end
- local event332 = Instance.new("RemoteEvent")
- event332.Parent = Workspace
- event332.Name = "DetailedChange"
- event332.OnServerEvent:connect(function(plr,location,NAME, newVal)
- location[NAME] = newVal
- end)
- SpawnVeza()
- while wait(RegenTime) do
- SpawnVeza()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement