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

FE, How do I send something to the Event?

I am doing this: (LocalScript):

local tool = script.Parent:WaitForChild("Tool")
game.Workspace.Events.GetTool:FireServer(tool)

But the Server script prints out nil

script.Parent.OnServerEvent:connect(function(player, tool)
	print(tool)
end)

Output: nil

How do I send that Information the the Event? Its a Tool.

1 comment

0

LOL, I have the same exact question!

1 answer

✓ Accepted answer

Local objects, like GUIs that get copied into each player's PlayerGui, don't exist on the server. They only exist locally on the client.

If you try to send a reference to them to the server (in a RemoteEvent or RemoteFunction) that object will be replaced with nil.

That is what's happening here.


It seems very strange that you would want to send a local object in GUI to the server... What is the meaning of the "GetTool" event? What kind of information does it need, and what kind of action does it take?

Probably you should instead indicate a tool in some shared service, like ReplicatedStorage.

local tool = game.ReplicatedStorage:WaitForChild("Tool")

game.Workspace.Events.GetTool:FireServer(tool)

2 comments

0

Its a Tool in PlayerGui. I want the Tool move from PlayerGui into his Character.

2

I do not understand as to why you would store the tool in PlayerGui. Use ReplicatedStorage and just clone the tool from there and parent it to the player's backpack.

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