hi i just made equip pets script and is no work… can anyone tell me why is broken?
here is the code:
local enabled = false
local Mps = game:GetService("MarketplaceService")
local Gamepasses = require(game.ReplicatedStorage.Modules.Gamepasses)
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Down:Connect(function()
if enabled == false then
enabled = true
local char = player.Character
local pets = game:GetService("ReplicatedStorage"):WaitForChild("Pets")
if char~=nil and pets then
local pp = player:WaitForChild("Pets")
local getp = 0
for g,h in pairs(player:WaitForChild("PetsEquiped"):GetChildren())do
if tostring(h) == tostring(script.Parent.Parent.Name) then
getp = getp + 1
end
end
if script.Parent.Parent:WaitForChild("BOOL").Visible == false then
if pp:FindFirstChild(tostring(script.Parent.Parent.Name)) and pp[tostring(script.Parent.Parent.Name)].Value > getp then
if not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet1") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet1"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet2") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet2"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet3") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet3"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet4") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet4"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet5") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) and Mps:UserOwnsGamePassAsync(player.UserId, Gamepasses.Pets5) or player.Name == "ClubCity" or player.Name == "TeamGaza" or player.Name == "CarbonMeister" or player.Name == "YT_FrogRoblox" or player.Name == "CDTV_DAD" then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet5"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet6") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) and Mps:UserOwnsGamePassAsync(player.UserId, Gamepasses.Pets5) or player.Name == "ClubCity" or player.Name == "TeamGaza" or player.Name == "CarbonMeister" or player.Name == "YT_FrogRoblox" or player.Name == "CDTV_DAD" then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet6"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet7") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) and Mps:UserOwnsGamePassAsync(player.UserId, Gamepasses.Pets5) or player.Name == "ClubCity" or player.Name == "TeamGaza" or player.Name == "CarbonMeister" or player.Name == "YT_FrogRoblox" or player.Name == "CDTV_DAD" then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet7"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet8") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) and Mps:UserOwnsGamePassAsync(player.UserId, Gamepasses.Pets5) or player.Name == "ClubCity" or player.Name == "TeamGaza" or player.Name == "CarbonMeister" or player.Name == "YT_FrogRoblox" or player.Name == "CDTV_DAD" then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet8"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
elseif not char:WaitForChild("HumanoidRootPart"):FindFirstChild("pet9") then
if player:WaitForChild("Pets"):FindFirstChild(tostring(script.Parent.Parent.Name)) and Mps:UserOwnsGamePassAsync(player.UserId, Gamepasses.Pets5) or player.Name == "ClubCity" or player.Name == "TeamGaza" or player.Name == "CarbonMeister" or player.Name == "YT_FrogRoblox" or player.Name == "CDTV_DAD" then
script.Parent.Parent.BOOL.Visible = true script.Parent:WaitForChild("Info").Text = "Unequip"
local vv = Instance.new("StringValue")
vv.Value = "pet9"
vv.Name = tostring(script.Parent.Parent.Name)
vv.Parent = player:WaitForChild("PetsEquiped")
end
end
end
else
local pets = player:WaitForChild("PetsEquiped")
if pets:FindFirstChild(tostring(script.Parent.Parent.Name)) then
pets[tostring(script.Parent.Parent.Name)]:Destroy()
script.Parent.Parent:WaitForChild("BOOL").Visible = false
script.Parent:WaitForChild("Info").Text = "Equip"
end
end
end
wait(1)
enabled = false
end
end)
there is no error on console.