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

Cloning a hat using a RemoteEvent: Argument 1 missing or nil (FilteringEnabled)?

I'm trying a clone a hat onto a player's character from ReplicatedStorage but it says Argument 1 missing or nil. I'm new to RemoveEvents and RemoteFunctions so I need a little bit of help.

LocalScript in a TextButton It says Argument 1 is missing or nil on the InvokeServer() part.

script.Parent.MouseButton1Down:connect(function()
local hat = game.ReplicatedStorage.CoolBoyHair:Clone()
workspace.Remote.GarrickHat:InvokeServer(hat)
end)

Script in ServerScriptService

local GarrickHat = workspace.Remote.GarrickHat

function GarrickHat.OnServerInvoke(player, hat)
	local g = game.ReplicatedStorage:FindFirstChild(hat)
	if hat then
		hat:Clone().Parent = player.Character
	end
end

1 answer

✓ Accepted answer

It seems as though you had wanted FireServer() instead. InvokeServer() is meant for returning values back to the client after the client has sent something. FireServer acts just like a regular event, unlike InvokeServer. It is returning nil because you hadn't returned anything, and it doesn't look like you need to return anything. If you need help setting up the format for FireServer() and OnServerEvent(), here's the link for the wiki page on it. Make sure that GarrickHat is a RemoteEvent as well. Also, you don't need to do FindFirstChild if you send an instance through the arguments.

2 comments

0

Thanks so much, it worked!

0

No problem

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