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 4 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

local button = script.Parent.Button

button.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.SettingsEvents.ResetStats:FireServer(game.Players.LocalPlayer.leaderstats.Stage.Value)
    print("Button clicked ree.") --//This works perfectly fine.
end)

Server Script

local rE = game:GetService("ReplicatedStorage")
local setEvents = rE.SettingsEvents

setEvents.ResetStats.OnClientEvent:Connect(function(plr,StageVal)
    print(plr.Name.." set off the reset stats event.") --//This does not print fsr
    plr.leaderstats.Stage.Value = 1
end)

Thanks for taking your time. Any answers are appreciated.

1 answer

Log in to vote
1
Answered by
VVoretex 146
4 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 — 4y
0
Welcome! VVoretex 146 — 4y
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 — 4y
0
Thanks for the reputation btw! VVoretex 146 — 4y
Ad

Answer this question