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

Event:FireClient not working at all?

Asked by 2 years ago

This is the script that does the FireClient()

local localInvis = game:GetService("ReplicatedStorage")
local localHide = localInvis:WaitForChild("localHide")
local players = game:GetService("Players")
local player = players[script.Parent.Parent.Parent.Parent.Name]
script.Parent.MouseButton1Click:Connect(function()
    print("after")
    localHide:FireClient(player)
    print("fired to player "..player.Name)
end)

and this is the part of the localscript that does the function... (ignoring the code inbetween)

local Event = game.ReplicatedStorage.localHide
local SetInvisible = false
local GetInvisibleTable = {}

Event.OnClientEvent:Connect(function()
    -irrelevant code
end

Both of the print()-s in the script work, but the fireclient does not work i guess?

1 answer

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago

The reason is because MouseButton1Click doesn't work on a Server Script, Try this on a local script

Local Script:

local PlayersService = game:GetService("Players")

local player = PlayersService.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()

    -- Code

end)
0
But FireClient can only be called from the server? WatsPlayzROBLOX 80 — 2y
0
You could add another remoteEvent that fires from the client back to the server which fires the other remote event strangejmaster43 139 — 2y
0
Yea just the local script inside the button and it should work MattVSNNL 620 — 2y
Ad

Answer this question