Skip Stage button for obby game

Thanks for your answer, I put that in the script, but nothing happens. An orange line does appear beneath checkpointStat (= plr.leaderstats.Stage) and beneath plr.Character.Humanoid a red line.

This is the script in my button, which I assume is nothing wrong with:

You are setting the plr variable again when the function fires. Server scripts do not know what the local player is, because it is running for everyone. So localplayer does not exist. Thats why the firing event looks like FireServer(plr) because it sends the player who fired the event, which can be used in the function. So remove this:

local plr = game.Players.LocalPlayer

from the OnServerEvent:Connect(Function(plr) function.

EDIT: I also see you did nothing with plr.Character.Humanoid. That is why it is red lining, it is a useless line without doing anything to it.
Change it to this:

plr.Character.Humanoid.Health = 0

Hello, I removed it and added the plr.Character.Humanoid.Health = 0, but the script doesn’t do anything and the lines are still there. i also get no error in the output

Oh, I forgot
checkpointStat needs local before it.
That should fix your issue.
Also in that picture, I see you still have plr.Character.Humanoid at the top. It is a line that does nothing, which is why it is red lining. The script will not function if it runs into an error.
Remove

plr.Character.Humanoid

Since you haven’t replied in a while, just thought I should bring this to your attention, since I saw that this is your first post on the DevForums.

Remember that if somebody solves your issue to click Solution on their reply, so that others know that your issue has been solved. You can also use the heart button as a thank you.

1 Like

Hey, thanks for your help, yes I know about the solution button. I just tried it and there’s no error and no red lines, but the script isn’t doing anything than closing the button when I click it. Should the place be published before trying?

It shouldn’t need published. Can you try debugging?
such as…
In the button script:

print("Clicked")

and then in the Remote Event…

print("Fired")

If it is not killing the player, it is probably not firing the event.
Remember to check Output which can be found here:


to see if the scripts report an error.

Can you also send a picture of in the RemoteEvent script?

It only says clicked, so I guess the event isn’t firing, because it isn’t doing anything else.

I also think the checkpointscript has some protection against changing the calue like this. Because when I removed the RemoteEvent and let it happen with a normal function, it increased the value on the leaderboard, killed the player, but the player was still at stage 1. So I think that, if this doesn’t work, it needs to be a skip-stage script with teleport function.

This is because of Filtering Enabled.
With a local script, changes only happen locally.
If you use the Remote Event approach, the changes will happen for everyone.

The script is grabbing the value of which checkpoint you are at, and even if you can see that your value has gone up, thats because the server does not. You can prove this by, when in play mode, changing the value while in Client, then moving to server. The value has not changed, but in Client it has. This is a representation of the player using an exploit to change the value, it only happens for them.

If you want to go with teleporting, we can. I will start by showing you the method for teleporting the player, since I understand your checkpoint script a little better.

You will only need a LocalScript for this. (Note that this may trigger any anti-cheats for teleport hacks. If you have any, that is.)

local offset = CFrame.new(0, changeme, 0) -- Set this for how far above the location the player needs to teleport.
local plr = game.Players.LocalPlayer
local checkpoints =   -- You will need to setup where your checkpoints are stored. 
  -- Do not pick a checkpoint, just the container of the checkpoints

script.Parent.TextButton.MouseButton1Click:Connect(function() -- function
    -- So now we figure out what the players next checkpoint is.
  local nextcheckpointnumber =  plr.leaderstats.Stage + 1
  -- This simply gets the players checkpoint, and stores it with an extra 1. It does not change the Checkpoint number.
  plr.Character.HumanoidRootPart.CFrame = checkpoints[nextcheckpointnumber].CFrame * offset
  
end)

Since this will be a localscript, if you have errors on the LocalScript after clicking the button while the player is still loading everything, I reccomend you use WaitForChild. API is in that link.

Thank you really much for the detailed explanation, I understand it now. Thanks for the teleportation script too! I am not at home right now, I will try it as soon as I can. Again, thanks for your help! :slight_smile:

1 Like

Hey, sorry for bothering again. I tried the teleport script today but got an error, do you know how to fix this?

The script:

Sorry for the late reply, I was taking a bit of a break.

That should work, since using game.Workspace is just like using game[“Workspace”]
Maybe try and find this same issue on the DevForum or elsewhere?

I can’t help right now as I am a bit busy, sorry. If you are still having issues I will get back to you when I can. Hope you get your issue resolved!

1 Like

Hey np, I am taking a break too, I searched a pretty long time for a fix, but didn’t find it so I decided to stop working on my game for now and maybe try to find a solution in a while again. Don’t be sorry, I will be patient! Again, thanks for helping me. :slight_smile:

Now that I have the time, I looked back and I think I know exactly whats wrong.
You can’t add numbers to an instance. That was my fault. Try converting the instances name into a number. Heres what I might try:

  1. Converting the instance into a string
  2. Convert string into a number variable

Look at the documentation or search around online if you can’t figure it out!

Edit: I realized now you can simply index an instance with .Name which makes it a string.

So, try this:

local offset = CFrame.new(0, changeme, 0) -- Set this for how far above the location the player needs to teleport.
local plr = game.Players.LocalPlayer
local checkpoints =   -- You will need to setup where your checkpoints are stored. 
  -- Do not pick a checkpoint, just the container of the checkpoints

script.Parent.TextButton.MouseButton1Click:Connect(function() -- function
    -- So now we figure out what the players next checkpoint is.
  local nextcheckpointnumber =  plr.leaderstats.Stage.Name + 1
  -- This simply gets the players checkpoint, and stores it with an extra 1. It does not change the Checkpoint number.
  plr.Character.HumanoidRootPart.CFrame = checkpoints[nextcheckpointnumber].CFrame * offset
  
end)