Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Event:FireClient not working at all?

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

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)

3 comments

0

But FireClient can only be called from the server?

0

You could add another remoteEvent that fires from the client back to the server which fires the other remote event

0

Yea just the local script inside the button and it should work

This discussion is preserved as it was. New answers, comments, and votes are closed.