Ad
Log in to vote
0

Error: invalid argument #3 (string expected, got nil)?

Asked by 7 days ago
Edited 7 days ago

I get this error: invalid argument #3 (string expected, got nil). These are the scripts:

Server script:

local rigs = game.Workspace.Rigs:GetChildren()
local event = game.ReplicatedStorage.RigTouched

for _, rig in pairs(rigs) do
    rig.OpenGuiPart.ClickDetector.MouseClick:Connect(function(player)
        local rigID = rig.ClothingID.Value
        event:FireClient(player, rigID)
    end)
end

Local script:

local event = game.ReplicatedStorage.RigTouched
local CurrentClothingID = script.Parent.ShopBackround.CurrentClothing

event.OnClientEvent:Connect(function(player, rigId)
    script.Parent.ShopBackround.Visible = true
    CurrentClothingID.Value = rigId
    print(rigId)
end)

I have read the code several times but still do not understand what is the problem. The error is on line 6 of the local script.

0
Try removing the "player" inside the parameters (Script) because when your firing those event roblox already knows the player so you dont need to put it acediamondn123 73 — 7d
0
To the person above me, this is incorrect. OnClientEvent has no player argument. Only OnServerEvent has this. deeskaalstickman649 388 — 7d

1 answer

Log in to vote
0
Answered by
NGC4637 227 Moderation Voter
6 days ago
Edited 6 days ago

I see the mistake. You see, only OnServerEvent needs the player argument. OnClientEvent doesn't. So on the local script, do this instead:

local event = game.ReplicatedStorage.RigTouched
local CurrentClothingID = script.Parent.ShopBackround.CurrentClothing

event.OnClientEvent:Connect(function(rigID)
    script.Parent.ShopBackround.Visible = true
    CurrentClothingID.Value = rigId
    print(""..rigID)
end)
0
also, in the server script, you gave the parameter rigID, so on the local script you have to do rigID too instead of rigId NGC4637 227 — 6d
Ad

Answer this question