local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local ServerStorage = game.ServerStorage
local NPCs = ServerStorage.NPCs
local Deb = game:GetService("Debris")
local Stats = require(game.ReplicatedStorage.Modules.BuildingStats)
local HouseTableEvents = {}
local WorkTableEvents = {}
local RoadsTableEvent = {}
Players.PlayerAdded:Connect(function(Player)
function Run()
for _, TaggedHouse in ipairs(game.Workspace[Player.Name.."Plot"]:GetChildren()) do
if TaggedHouse:IsA("Model") then
if Stats[TaggedHouse.Name].Type == "House" then
table.insert(HouseTableEvents, {TaggedHouse.CarDoor.Position})
end
end
end
end
local function UpdateClickConnectionHouse(Part)
for i=1, (10) do --Player.Stats.Population.Value/40
for _, HouseTable in ipairs(HouseTableEvents) do
for _, Position in ipairs(HouseTable) do
wait(1)
local Clone = NPCs.Car:Clone()
print(Position)
Clone.Parent = game.Workspace.NPCFolder
Clone.Position = Position
print(Clone.Position)
HouseTable = nil
Deb:AddItem(Clone, 10)
Run()
end
end
end
end
local function UpdateClickConnectionWork(Part)
for _, WorkTable in ipairs(WorkTableEvents) do
end
end
local function UpdateClickConnectionRoads()
for _, RoadsTabel in ipairs(RoadsTableEvent) do
end
end
wait(.1)
local Plot = Player.Name.."Plot"
workspace[Plot].ChildAdded:Connect(function(Part) -- Part Arguemtn
wait()
UpdateClickConnectionHouse(Part)
UpdateClickConnectionWork(Part)
UpdateClickConnectionRoads()
Run()
end)
workspace[Plot].ChildRemoved:Connect(function() -- Part Argument
UpdateClickConnectionHouse()
UpdateClickConnectionWork()
UpdateClickConnectionRoads()
Run()
end)
Run()
UpdateClickConnectionHouse()
end)
I tried what seems like everything. Any advice?