Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

CFrame of leaderstats value?

I've been looking for a checkpoint script for my obby since the one I tried doing myself doesn't work no matter what I try. I came across a script here:

function oa(object)
    local player = game.Players:playerFromCharacter(object)
    if player ~= nil then
        local ls = player.leaderstats
        local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
        print("obby")
        object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
        wait()
        object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
    end 
end

game.Workspace.ChildAdded:connect(oa)

I understand most of the script, but I don't understand how sl can have a CFrame. Can someone please explain it to me? Thank you!

Edit: I've looked it over more, and I see that line 9 doesn't make sense. The player is in game.Players, not the Workspace, so line 9 returns nil. I've seen it work for others, but I don't understand how it works. :/

1 comment

0

No! line 9 is not the player but it is the player's character!

1 answer

✓ Accepted answer

The "sl" is most likely a SpawnLocation/Checkpoint or a part, since its in Workspace. If you need more of an explanation, don't hesitate to ask!

Edit:

I just looked at your script again, and I think I see a problem Line 2: local player = game.Players:playerFromCharacter(object) should be replaced with local player = game.Players:GetPlayerFromCharacter(object). Hopefully that helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.