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

PlayerAdded CFrame stuff. pls help?

Asked by 4 years ago
Edited 4 years ago
game.Players.PlayerAdded:Connect(function()
    game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
    wait(.1)
    game.Players.LocalPlayer.Character.Torso.CFrame = 
    game.Workspace[game.Players.LocalPlayer.leaderstats.Stage.Value].CC.CFrame
end)

When i tested it in my obby, when i spawned in i didn't teleport to for example stage 0 when i just join, instead i just spawn high up in the middle of the baseplate. But when resetting i spawn on the checkpoint (stage).

This is a localscript inside workspace, im really confused how this isn't working. Already have everything else setup like stages, teleport to them when they die/respawn.

0
You cant write, game.Players.LocalPlayer, In a normal script. Lava_Scripter 109 — 4y
0
bro read, i said localscript at the bottom. popu2004 42 — 4y

1 answer

Log in to vote
0
Answered by
Nikkulaos 229 Moderation Voter
4 years ago
Edited 4 years ago

If its a localscript then this will do:

local player = game.Players.LocalPlayer
repeat wait() until player.Character ~= nil
local character = player.Character
    wait(.1)
character.Torso.CFrame = 
game.Workspace:FindFirstChild(player.leaderstats.Stage.Value).CC.CFrame

If you want it in a serverscript, just do this:

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
    wait(.1)
    character.Torso.CFrame
game.Workspace:FindFirstChild(player.leaderstats.Stage.Value).CC.CFrame
end)
end)

Tell me if these helped!

0
Tysm! :D popu2004 42 — 4y
0
Np! Nikkulaos 229 — 4y
Ad

Answer this question