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 3 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:

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

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

You have to pass a player instance to InvokeClient()

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

Answer this question