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

Why doesn't this remote event work? No error in the output.

Asked by 5 years ago

I want to make a RemoteEvent which will reset the player's Stage stats to 1. This however is not working. So I made a ScreenGui and used a RemoteEvent and picked up that event in a serverScript. No errors in the output have shown.

Local Script

1local button = script.Parent.Button
2 
3button.MouseButton1Click:Connect(function()
4    game.ReplicatedStorage.SettingsEvents.ResetStats:FireServer(game.Players.LocalPlayer.leaderstats.Stage.Value)
5    print("Button clicked ree.") --//This works perfectly fine.
6end)

Server Script

1local rE = game:GetService("ReplicatedStorage")
2local setEvents = rE.SettingsEvents
3 
4setEvents.ResetStats.OnClientEvent:Connect(function(plr,StageVal)
5    print(plr.Name.." set off the reset stats event.") --//This does not print fsr
6    plr.leaderstats.Stage.Value = 1
7end)

Thanks for taking your time. Any answers are appreciated.

1 answer

Log in to vote
1
Answered by
VVoretex 146
5 years ago

Ok you fired a server in the localscript and you used OnClientEvent in the server

0
I'm so dumb I didn't even realise that. I can't believe i didn't see that. Thanks a lot though for taking your time! kingblaze_1000 359 — 5y
0
Welcome! VVoretex 146 — 5y
0
The first argument of OnServerEvent is the player that fired the event. After is the argument that you have sent by the client. NiniBlackJackQc 1562 — 5y
0
Thanks for the reputation btw! VVoretex 146 — 5y
Ad

Answer this question