I would like to note first there is no problem with my script, rather it is a roblox server problem I think and what I'm trying to portray below isn't a script.
This is has been my biggest problem so far, I have a GUI that changes a person's leaderstats(e.g stage = 1,2,3 etc) a simple IntValue to keep track of what stage a person is...
Now when I check to see how my script is running in Test -> Local Server -> 1 Player
There's usually 2 more roblox studio that pops up, 1 for the server and another for the 1 Player.
I check the Explorer's Tab and Properties Tab for the Local Server and here is what I see:
(THIS IS NOT A SCRIPT) LOCAL SERVER:
1 | ------------------EXPLORER TAB----------------------- |
2 | Players |
3 | '->Player 1 |
4 | '->LeaderStats |
5 | '->stage |
6 | ----------------------------------------------------------------- |
----------------PROPERTIES TAB-----------------------
I click the Next Stage Button on the Player1 Studio and I see the Value of the Stage increase to 1 FOR THE PLAYER1 STUDIO ONLY.
I checked back to see if the Server Studio changed, and it still remains the same!
I think the problem here is I'm using a local gui, therefore the Server Studio cannot see the changes, BUT my GUI won't work if I won't use a LocalScript.
I would need some advice regarding this matter, or a solution to my problem would also help.
(P.S Sorry for the bad explanation)
Is filtering enabled turned on? If yes, then you need to make a remote event to do that, as local scripts only work for the client and not the server. It's simple. Just insert a remote event to ReplicatedStorage and call it whatever you want.
Here's the script for the gui:
1 | local button = script.Parent |
2 |
3 | button.MouseButton 1 Click:Connect( function () |
4 | game:GetService( "ReplicatedStorage" ).RemoteEvent:FireServer( 1 ) --the one is how much stages you want to add |
5 | end ) |
Now add another script at the ServerScriptService and put this code
1 | game:GetService( "ReplicatedStorage" ).RemoteEvent.OnServerEvent:Connect( function (player, amount) |
2 | game.Players [ player.Name ] .leaderstats.Stage.Value = game.Players [ player.Name ] .leaderstats.Stage.Value + amount |
3 | end ) |
And if I make any spelling differences, just edit them!
I highly recommend you to learn more about remote events, as they are super helpful :)