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

Can someone help me with FireClient() and OnClientEvent not working?

I have a script meant to give me an item, and I can't get the remote event to work with FireClient. Here's what I have so far:

localscript:


script.GiveItem.OnClientEvent:Connect(function(item,amount)
--item giving code didn't put because it's too long
end)

normal script:

canGive = true


script.Parent.Touched:Connect(function(hit)
	if canGive == true then
	canGive = false
	
	play = game.Players:GetPlayerFromCharacter(hit.Parent)
	
	play.PlayerGui.Inventory.InvScript.GiveItem:FireClient(play,"CopperShortsword",1)

	end
end)

Notes: -play is not null, I already tested that -the problem isn't with the item giving code, tested that too

4 comments

0

Is the function in the local script being run at all or does the function have a error? Put a print in it.

0

Prints don't send anything to my output (even if I put it first line)

0

The entire point of client events is for the server to not access the client. By putting the RemoteEvent inside of the client, you essentially made it invisible to the server. Put the RemoteEvent in ReplicatedStorage instead.

0

Still ins't working

1 answer

You have to put a RemoteEvent in Replicated storage and name it whatever

(Name of RemoteEvent).OnClientEvent:Connect(function(item,amount)

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