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

Argument 1 missing or nil error in RemoteFunction?

I got an error trying to use a RemoteFunction from server to client to try and create a Hitmarker. I couldn't find any way to fix it, so i decided i was going to ask it here.

Error:

Argument 1 missing or nil

Server Script:

local humanoid = part.Parent:FindFirstChild("Humanoid")

if humanoid then
	game.ReplicatedStorage.Hitmarker:InvokeClient()
	if part.Name == "Torso" then
		Damage = 8
	elseif part.Name == "HumanoidRootPart" then
		Damage = 8
	elseif part.Name == "Head" then
		Damage = 15
	else
		Damage = 5
	end
	humanoid.Health = humanoid.Health - Damage
end

Local Script:

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Icon = "http://www.roblox.com/asset?id=117431027"

game.ReplicatedStorage.Hitmarker.OnClientInvoke = function()
	mouse.Icon = "http://www.roblox.com/asset/?id=1324497959"
end

Any help would be appreciated!

1 answer

✓ Accepted answer

You have to pass a player instance to InvokeClient()

if humanoid then
    local player = game.Players:GetPlayerFromCharacter(part.Parent)
    game.ReplicatedStorage.Hitmarker:InvokeClient(player)

1 comment

0

It worked! Thanks for the response!

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