On line 5(
... if player:WaitForChild("Data").Items:FindFirstChild(item) then ...) it throws an error which is the title; I’ve tried multiple ways of this, and rechecked that the
player argument and the
item argument were not nil.
I think that I would have to silence the 1st argument with nil(
...Items:FindFirstChild(nil, item)) which is in the function, but, as soon as i did that it gave me the same error.
Anyone knows how to fix that?
This is a server script;
Remote was called from
Here’s a script that i have right now:
local rs = game:GetService("ReplicatedStorage") rs.pickupitem.OnServerEvent:Connect(function(player, item) if player:WaitForChild("Data").Items:FindFirstChild(item) then print(player.." already has the item") else local thingthatadded = Instance.new("IntValue") thingthatadded.Parent = player:WaitForChild("Data").Items thingthatadded.Name = "TestItem" if thingthatadded.Value == 0 then thingthatadded.Value = 1 elseif thingthatadded.Value > 0 then thingthatadded.Value = thingthatadded.Value + 1 end end end)
tl;dr i need it so that i wouldn’t get the error anymore
If you need more details, take a look at the following algorithm.
Its messy. I know.