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

Stage not resetting when clicked? (obby)

here is my script:

script.Parent.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.leaderstats.Stage.Value = 0
end)

what i am trying to reach here is that im making a GUI to reset the player's stage. (for an obby.) i am also using a server script. (does it require a local script???)

if further information is needed, please contact me.

3 comments

0

This won't work if you're doing it in a localscript due to filteringenabled, try firing a remote event to the server to let it know that you want to reset your stage

0

First, you can't call LocalPlayer with a sever script. And second, you will need a local script, and a function that fires the server to change the value.

0

Yup

1 answer

✓ Accepted answer

Inside your button you press to reset the stage, inset a local script and insert this into it

player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.RemoteEvent:FireServer(player)
end)

All this does is tell the server the event has been fired

Also insert a normal script into the button, and insert a RemoteEvent, and then use this code in the normal script

RemoteEvent = script.Parent.RemoteEvent
player = script.Parent.Parent.Parent.Parent -- goes from the script to the player

RemoteEvent.OnServerEvent:Connect(function()
	player.leaderstats.Stage.Value = 0
end)

This tells the event what to do, and in this case it resets the stage to 0. The event makes it so that the change is seen both on the server and the client.

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