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

How to send a server item to client?

So what I mean by this is I need to try send an item in Workspace as a variable and fire it to the client. The client is mean to pick this is up and set it as a local, but however this is not the case. It returns in the client as 'nil'.

--Server Script:
--I do have a local for the Player

local item = game.Workspace.Item
local event = game.ReplicatedStorage.ReVent
ReVent:FireClient(Player, item)

print(item) -- this works

The script is in ServerScriptService by the way.

--Client Local Script (PlayerGui)

ReVent.OnClientEvent:Connect(function(Player, item)
print(item) -- prints nil
end)

Any help?

2 answers

✓ Accepted answer

For OnClientEvent, the first parameter isn't the player firing the client - that's for OnServerEvent

ReVent.OnClientEvent:Connect(function(item)
    print(item)
end)

OnClientEvent doesn't receive a Player parameter.

--Client Local Script (PlayerGui)

ReVent.OnClientEvent:Connect(function(item) -- removed 'Player'
print(item) -- prints nil
end)

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