Im trying to send a remote event to open a gui and whenever the game opens this error pops up..
-- script
local event = game.ReplicatedStorage:WaitForChild("TriggerSignPopUp")
event.OnClientEvent:Connect(function(player)
player.PlayerGui.CoronaVirusFrontController.Enabled = true
end)
The Error:
-- error
- OnClientEvent can only be used on the client
- Stack Begin
- Script 'ServerScriptService.Script', Line 3
- Stack End
And here's the script that's firing it:
-- local script
local clickdetector = script.Parent:WaitForChild("ClickDetector")
local event = game.ReplicatedStorage:WaitForChild("TriggerSignPopUp")
local player = game.Players.LocalPlayer
local groupid = 8333540
local cd = false
clickdetector.MouseClick:Connect(function()
if player:GetRankInGroup(groupid) >= 5 and not cd then
event:FireClient(player)
cd = true
wait(4)
cd = false
elseif cd then
print("on cooldown")
end
end)

1 comment
You can't do FireClient in a local script, Change the FireClient to FireServer, and OnClientEvent to OnServerEvent