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

Why my checkpoint system is just teleporting me to the stages?

Asked by 3 years ago
Edited 3 years ago

I am trying to make an obby that uses checkpoints and saves the data, i have tested it with my friends but it only teleports me to the stage i left. Help please.

Server Script:

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
        repeat wait() until Player.Character ~= nil
        if Stage.Value == 0 then return end
        local Checkpoint = game.Workspace:FindFirstChild(Stage.Value)
        if Checkpoint then
            char:MoveTo(game.Workspace[tostring(Stage.Value)].Position)
        end
    end)
end)

The checkpoints name are the same as of its stage. No errors.

Thanks. If you want more information ask.

0
i think uhhh u have to use saving on user id idk IEntity_303I 80 — 3y
0
I already did that. However, thats not the problem. yuni_Boy1234 320 — 3y
0
What do you mean by 'but it only teleports me to the stage i left'? PeculiarTea 0 — 3y
0
Well, i am the only one who the script teleports to the stage i left, while others players don't yuni_Boy1234 320 — 3y

2 answers

Log in to vote
0
Answered by
7zjh 146
3 years ago
Edited 3 years ago

Quite a stupid question.

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
        repeat wait() until Player.Character ~= nil
        if Stage.Value == 0 then return end
        local Checkpoint = workspace:FindFirstChild("Stage")
        if Checkpoint then
            char:MoveTo(tonumber(Checkpoint.Value))
        end
    end)
end)

tell me if that works.

0
I see the problem now. 7zjh 146 — 3y
0
The varriable Checkpoint is a Value under workspace and you are trying to get a Position from the value property. If it was a vector3 value, you would just do .Value under the supposed value. 7zjh 146 — 3y
0
I am sure this will not work, FindFirstChild function checks if a object is in the selected parent (Parent:FindFirstChild()) and its parameter is the object's name, it returns true if it finds, otherwise, it turns false, so you cant do "Checkpoint.Value" since boolean values doesn't have a value property, and on line 7, the move to function needs a vector3 value so it can move a player character. yuni_Boy1234 320 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Fixed it, just saw another youtube video on how to make checkpoints and followed his instructions, here is the final result:

function Teleport(Char)
    local Player = game.Players:GetPlayerFromCharacter(Char)
    if Player ~= nil then
        repeat wait() until Char.HumanoidRootPart ~= nil
        local ls = Player.leaderstats
        local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
        Char.HumanoidRootPart.CFrame = Char.HumanoidRootPart.CFrame + Vector3.new(0,3,0)
        wait()
        Char.HumanoidRootPart.CFrame = sl.CFrame + Vector3.new(0,3,0)
    end

end

game.Workspace.ChildAdded:Connect(Teleport)

However, anyone who answers why the old script didn't worked and this one yes, it will be marked as answer.

Answer this question