Hello Developers,
So I made a script which creates house and then keeps player in it, but I found an error saying there are no parts or models in a folder
the script:
local spawns = {game.Workspace.HouseSpawns:GetChildren()}
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Folder",plr)
stats.Name = "leaderstats"
local speed = Instance.new("IntValue",stats)
speed.Name = "Speed"
speed.Value = math.random(5,35)
plr.CharacterAdded:Connect(function(char)
local number = 1
for i,v in pairs(spawns) do
print(v.Name)
if v.CanTake == true then
number = tonumber(v.Name)
end
end
char.Humanoid.WalkSpeed = speed
local newhouse = game.ReplicatedStorage.House:Clone()
newhouse.Parent = workspace
newhouse.Name = plr.Name
newhouse:SetPrimaryPartCFrame(spawns[number].CFrame + Vector3.new(0,3,0))
char.HumanoidRootPart.CFrame = newhouse.PrimaryPart.CFrame + Vector3.new(0,5,0)
end)
end)