How do I make a Reset Stage Button work?

I’ve been searching for ways to script a Reset Stage Button for my obby game and I came across another DevForum topic and it’s the only one I think that matches my obby layout.

Link: How do I make a reset progress button that actually works?

I looked through the post and they explained it very well. I thought this would actually work. I put the Remote Event in ReplicatedStorage, I put the code into the Local Script and I was confused at first I didn’t know what the solver meant by, "on your your local script put
game.ReplicatedStorage.ResetStage:FireServer(clicked) "

I didn’t know where to put it in the local script though, so I put it into the original local script that they had. But the ServerScriptService script seemed right. I ran the game, clicked yes, and in the output it said
[Attempts is not a valid member of Folder].
The Stage Value changed to 1, but it didn’t reset me or teleport me to stage 1. I tried to manually reset, but i just stayed on the same stage

How can I fix this.

Sorry if I can’t be specific.This is my first DevForum post.

Thanks,
IDKWHOEYEAM

Could you put your code in so we can see the issue?

Also so as said before in the other post firing a remote event is basically sending information to the server from a local script that you cannot get in a script. So you are sending the clicked variable to the server so the server can receive it.

What it means by attemps is you did not set attemps to be a leaderstats value. So you need to set a value you you did with stage with the leaderstats folder. So after you get the leaderstats folder you do.

local Attemps = Instance.new("IntValue")
Attemps.Parent = clicked.leaderstats

Now what will happen is It’ll make a IntValue set like you have for stage and you have to change it on the server because it will only save or store your values on the server. You are getting clicked from the localscript since You cannot get the local player from the server.

ServerScriptService Script:
game.ReplicatedStorage.ResetStage.OnServerEvent:Connect(function(clicked)
clicked.leaderstats.Stage.Value = 1
clicked.leaderstats.Attempts.Value = 0
clicked.Char.Humanoid.Health = 0
end)
Local Script:
local button = script.Parent

button.MouseButton1Click:Connect(function()
local clicked = game.Players.LocalPlayer
print(clicked)
clicked.leaderstats.Stage.Value = 1
clicked.leaderstats.Attempts.Value = 0
clicked.Char.Humanoid.Health = 0
game.ReplicatedStorage.ResetState.Value = true
game.ReplicatedStorage.ResetStage:FireServer(clicked)
end)

So is Attemps a valid member of leaderstats?

Sorry, but which script do I put it in?

Right now I have script from HowToRoblox’s " How To Make An Autosave Obby" video, where do i put it?

Whenever I do

local Attempts = Instance.new(“IntValue”)
Attempts.Parent = clicked.leaderstats

It censors out clicked

and when I add it in the script and run it i spawn in the middle of no where.
How do I fix this?

How do you get those other leaderstats set?

I used HowToRoblox’s Autosave script and it made a leaderstat in the script

Alright so then what you want to do is set the Attempts on player joined so run a game.Players.PlayerAdded:Connect(function(plr) and then write the code under there.

Ok, so I put it in and it censored clicked again

and in the output it said

[ServerScriptService.ObbyHandler:8: attempt to index nil with ‘leaderstats’

and

[Attempts is not a valid member of Folder]

How do I fix this?

Join the game in studio then check the player for a folder named or something close to “leaderstats”

I did this before and the folder name is called “leaderstats”

I would recommend using a remote event to reset their stage.

If you use teams and spawn locations to handle it, then I think you could just get away with a LoadCharacter event.

If not, if you have a table of parts or positions for the stages, you could load their character then CFrame them to the position or just teleport them there.