Yes it keeps giving me that error
Can you post the full script that you have now?
wait(1);
local l__Pets__1 = game.Players.LocalPlayer:WaitForChild("Pets");
script.Parent.EquipButton.MouseButton1Click:Connect(function()
for v1, v2 in pairs(l__Pets__1:GetChildren()) do
spawn(function()
local Type = v2:FindFirstChild("Type")
if Type then
game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("PetActionRequest"):InvokeServer(unpack({ "Craft", {
PetID = v2.PetID.Value
} }));
end;
end);
end;
end);
I am using this one because I am using the remotefunction for something else too
I’m 99% sure the spawn is causing the issue you’re seeing. You can try task.spawn
instead as I think that runs instantly if you MUST use a RemoteFunction. See the Task library for additional details task | Roblox Creator Documentation
Nop this still gives me the error
Post the code again please? Hard to tell what’s going on without it.
wait(1);
local l__Pets__1 = game.Players.LocalPlayer:WaitForChild("Pets");
script.Parent.EquipButton.MouseButton1Click:Connect(function()
for v1, v2 in pairs(l__Pets__1:GetChildren()) do
task.spawn(function()
local Type = v2:FindFirstChild("Type")
if Type then
game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("PetActionRequest"):InvokeServer(unpack({ "Craft", {
PetID = v2.PetID.Value
} }));
end;
end);
end;
end);
Try this
task.wait(1);
local l__Pets__1 = game.Players.LocalPlayer:WaitForChild("Pets");
script.Parent.EquipButton.MouseButton1Click:Connect(function()
for v1, v2 in pairs(l__Pets__1:GetChildren()) do
local Type = v2:FindFirstChild("Type")
if Type then
local id = v2.PetID.Value
task.spawn(function()
game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("PetActionRequest"):InvokeServer(unpack({ "Craft", {
PetID = id
} }));
end);
end;
end;
end);
It works but still keeps giving the same error
Send a screenshot of the error now?
This just means that for each “pet” the child has when an attempt is made to locate a child instance named “v2” in each the child doesn’t exist. Check the pets in your pets folder, make sure you have correctly placed a child instance inside of each of them named “v2”.
v2 is nil. So do a check on that instead.
wait(1);
local l__Pets__1 = game.Players.LocalPlayer:WaitForChild("Pets");
script.Parent.EquipButton.MouseButton1Click:Connect(function()
for v1, v2 in pairs(l__Pets__1:GetChildren()) do
spawn(function()
if v2 and v2.Type.Value ~= "Amazing" then
game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("PetActionRequest"):InvokeServer(unpack({ "Craft", {
PetID = v2.PetID.Value
} }));
end;
end);
end;
end);
Still gives me the same error