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

CFrame of leaderstats value?

Asked by 4 years ago
Edited 4 years ago

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. :/

0
No! line 9 is not the player but it is the player's character! Mr_m12Ck53 105 — 4y

1 answer

Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
4 years ago
Edited 4 years ago

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!

Ad

Answer this question