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

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

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.

4 comments

0

i think uhhh u have to use saving on user id idk

0

I already did that. However, thats not the problem.

0

What do you mean by 'but it only teleports me to the stage i left'?

0

Well, i am the only one who the script teleports to the stage i left, while others players don't

2 answers

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.

3 comments

0

I see the problem now.

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.

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.

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.

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