Hello! I am making a script which makes the player spawn at a certain spawnpoint depending on the players stage value. I have looked at the devforum and could not find anything since I did not get any errors. Here is the script:
game.Players.PlayerAdded:Connect(function(player)
local ldr = Instance.new("Folder", player)
ldr.Name = "leaderstats"
local stage = Instance.new("IntValue", ldr)
stage.Name = "Stage"
stage.Value = 1
--|| Player died ||--
player.CharacterAdded:Connect(function(char)
local stage = "Stage"..player:WaitForChild("leaderstats").Stage.Value
local spawnDestination = game.Workspace[stage]:WaitForChild("Spawn")
local hrp = char:FindFirstChild("HumanoidRootPart")
print(hrp)
if hrp then
hrp.CFrame = spawnDestination.CFrame
end
end)
end)
I printed out the humanoidrootparts cframe and spawndestination cframe before and after assigning it. This is what I got:
The script shown above is a server script so you mean bindable event right? Or did I make a mistake by having the script in a server script rather than it being a local script?
But you cant have the “game.Players.PlayerAdded” function in local scripts and the script above runs for each player individually since thats how the function works. I updated my topic so now you should be able to see the whole script