I don’t know why its not working, I want the player to teleport to a part every time they spawn but it does not work
Script:
local part = script.Parent
while true do
player.CharacterAdded:Connect(function(char)
char:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame
end)
wait(0.1)
end
local player = game:GetService("Players")
local part = script.Parent
player.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame
end)
end)
so this didn’t work
but this did
local player = game:GetService("Players")
local part = script.Parent
player.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
task.wait(.1)
char:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame
end)
end)
for me, adding a task.wait(.1) fixed it.
U can leave the task.wait() blank if u want, still works.
Hi, So I only noticed now that I did not full past my script so here is my actual full scripts (I am trying to make a jail and I sorta new a scripting)
local part = script.Parent
local player
local command = {}
for word in string.gmatch(part.Name, "%S+") do -- finding player from name
table.insert(command, word)
end
local name = command[1]
player = game.Players:FindFirstChild(name)
player.CharacterAdded:Connect(function(char)
char:FindFirstChild("HumanoidRootPart").CFrame = part.CFrame
end)