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

Button with a remote event is not working?

Asked by 6 years ago

Hello

I'm making a button that when pressed it resets the kills and deaths stats in the leaderboard. However this doesn't work. I think my remote event doesn't work for somehow.

local script (This is under the button in the startergui)

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ResetEvent = ReplicatedStorage:WaitForChild("ResetEvent")

script.Parent.MouseButton1Click:Connect(function()
    ResetEvent:FireServer()
end)

Normal script (This is in the server script service


print("Hello World") local ReplicatedStorage = game:GetService("ReplicatedStorage") local ResetEvent = Instance.new("RemoteEvent",ReplicatedStorage) ResetEvent.Name = "ResetEvent" Players = game:GetService("Players") print("variables work") local function onResetEventFired() print("Reset Event fired") for i, player in pairs(Players:GetPlayers())do player.leaderstats.KOs.Value = 0 player.leaderstats.Wipeouts.Value = 0 print("Stats reset") end end print("Test") ResetEvent.OnServerEvent:Connect(onResetEventFired) print("The script read this")

I tried to add prints to debug the hello world and variables work print works, when pressing the buttons the other prints also still don't work.

Can someone help me?

Kees

0
It works now :) kees31ALT 5 — 6y

Answer this question