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

How do I make so the player needs to go in the obby checkpoints in order?

Asked by 4 years ago
Edited 4 years ago

Hello! I'm making an obby that has checkpoints, and I want to make the player need to go to the checkpoints in order. Because I don't want hackers to teleport from the first stage to the last stage.

I tried to make my script make sense but it does not and is of course not going to actually work

I tried making this script hoping it will work but that's before finding out that it does not make sense that it will work.

01local part = script.Parent
02 
03part.Touched:Connect(function(hit)
04    if hit.Parent:FindFirstChild("Humanoid") then
05        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
06        local stagesnow = player.leaderstats.Stage.Value
07        if player.leaderstats.Stage.Value ~= stagesnow - 1 then
08            stagesnow = stagesnow + 1
09            player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + stagesnow - 1
10        end
11        end
12end)
13 
14script.Parent.CheckPointScript.Disabled = true

So I am having trouble with that. What do I need to do so it can make sense?

0
there is a value inside the player called "RespawnLocation" (or something like that). Try experimenting with that (maybe set the script to update it to that part). JustAnotherGaming 48 — 4y

1 answer

Log in to vote
0
Answered by
zane21225 243 Moderation Voter
4 years ago

Hello friend! I was also having this same issue around a year ago. Here's the fix for it:

1script.Parent.Touched:Connect(function(touched)
2    local plr = game.Players:GetPlayerFromCharacter(touched.Parent)
3    local stageCount = plr.leaderstats.Stage
4    if stageCount.Value -> stageCount.Value + 1 then
5        stageCount.Value = stageCount.Value + 1
6    elseif stageCount.Value > stageCount.Value + 1 then
7        touched.Parent.Humanoid.Health = 0
8    end
9end)

Basically what I did here was I checked if the player was gaining more than a single stage at a time, it just automatically kills the player.

Ad

Answer this question