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

Argument 1 missing or nil error in RemoteFunction?

Asked by 4 years ago

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:

01local humanoid = part.Parent:FindFirstChild("Humanoid")
02 
03if humanoid then
04    game.ReplicatedStorage.Hitmarker:InvokeClient()
05    if part.Name == "Torso" then
06        Damage = 8
07    elseif part.Name == "HumanoidRootPart" then
08        Damage = 8
09    elseif part.Name == "Head" then
10        Damage = 15
11    else
12        Damage = 5
13    end
14    humanoid.Health = humanoid.Health - Damage
15end

Local Script:

1local mouse = game.Players.LocalPlayer:GetMouse()
2 
4 
5game.ReplicatedStorage.Hitmarker.OnClientInvoke = function()
7end

Any help would be appreciated!

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
4 years ago

You have to pass a player instance to InvokeClient()

1if humanoid then
2    local player = game.Players:GetPlayerFromCharacter(part.Parent)
3    game.ReplicatedStorage.Hitmarker:InvokeClient(player)
0
It worked! Thanks for the response! ColdFoxy07 76 — 4y
Ad

Answer this question