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

OnClientEvent Function not Firing?

Hi. I've been doing an Ammo GUI, and one of the things I need to do is have a RemoteEvent FireClient whenever a tool is equipped, and whenever the ammunition values change, it also fires a different RemoteEvent. The two RemoteEvents are created by a server script, and stored under ReplicatedStorage in a Group, under the player's name. The client script then accesses these RemoteEvents, and listens for any time the client event is fired. However, the Client Script function doesn't fire. Here's the relevant code; thank you if you try to help:

Server Script:

functionGroup:WaitForChild("ToolEquipped"):FireClient(player, tool.Name, tool.Main.Ammo, tool.Main.StoredAmmo)
		tool:WaitForChild("Main").Ammo.Changed:connect(function()
			functionGroup:WaitForChild("AmmoChanged"):FireClient(player, tool.Main.Ammo, tool.Main.StoredAmmo)
		end)

Client Script:

functionGroup:WaitForChild("AmmoChanged").OnClientEvent:connect(function(plr, ammo, storedAmmo)
	print("Connected to Client AmmoChanged Function")
	if ammo ~= nil and storedAmmo ~= nil then
		updateGUI(ammo, storedAmmo)
		print("Now Updating GUI")
	end	
end)

1 answer

For an OnClientEvent, you don't need to have the first parameter to be a player, that's only when you are firing TO the client. If you remove the first parameter in the Client Script, it should work fine.

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