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

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

Asked by 6 years ago

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

0
Is the function in the local script being run at all or does the function have a error? Put a print in it. Wafflecow321 457 — 6y
0
Prints don't send anything to my output (even if I put it first line) Professor_Boxtrot 136 — 6y
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. UnityAlex 36 — 6y
0
Still ins't working Professor_Boxtrot 136 — 6y

1 answer

Log in to vote
0
Answered by 5 years ago

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

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

Answer this question