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

How to send a server item to client?

Asked by
Scaii_0 145
5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

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

ReVent.OnClientEvent:Connect(function(item)
    print(item)
end)
Ad
Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
5 years ago

OnClientEvent doesn't receive a Player parameter.

--Client Local Script (PlayerGui)

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

Answer this question