Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this not work in CharacterAdded?

Asked by
Rhuxus 25
8 years ago
function respawn(c,s)
local spots={'A','B','C','D'}
local newspawn = spots[math.random(1,#spots)]
c.Torso.CFrame = workspace[s][newspawn].CFrame
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
respawn(character,'Civilians')
end)
end)

It works when I run it in dev console as

function respawn(c,s)
local spots={'A','B','C','D'}
local newspawn = spots[math.random(1,#spots)]
c.Torso.CFrame = workspace[s][newspawn].CFrame
end
respawn(workspace.Rhuxus,'Civilians')

But not in the characteradded

Any idea why?

0
what type of script is this koolkid8099 705 — 8y
0
It's suppose to move the character to one of four spots on the map every time they spawn. Rhuxus 25 — 8y
0
Also it's a regular script in serverscriptservice Rhuxus 25 — 8y

Answer this question