I am trying to make a equip pet button but It’s giving an error
Local script
equipbtn.MouseButton1Click:Connect(function()
if (selctedTemplate ~= nil) then
local result = game.ReplicatedStorage.Equip:InvokeServer(selctedTemplate.Name)
print(result)
if result == "Equip" then
script.Parent.Value.Value = script.Parent.Value.Value +1
equipbtn.Text = "Unequip"
selctedTemplate:FindFirstChild("Value").Value = true
else
script.Parent.Value.Value = script.Parent.Value.Value -1
equipbtn.Text = "Equip"
selctedTemplate:FindFirstChild("Value").Value = false
end
end
end)
Server Script
local pass = 22995691
game.ReplicatedStorage.Equip.OnServerInvoke = function(player,petName)
if player.PetInventory:FindFirstChild(petName) then
if workspace.PlrPets:FindFirstChild(player.Name) then
if #game.Players:FindFirstChild(player.Name).PlayerGui:WaitForChild("handler").Value.Value <= 5 then
return "Equip"
elseif #game.Players:FindFirstChild(player.Name).PlayerGui:WaitForChild("handler").Value.Value == 5 then
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, pass) then
local pet = game.ReplicatedStorage.Pets:FindFirstChild(petName, true)
if pet ~= nil then
local cloned = pet:Clone()
cloned.Parent = workspace.PlrPets:FindFirstChild(player.Name)
end
return "Equip"
else
return "UnEquip"
end
end
elseif #game.Players:FindFirstChild(player.Name).PlayerGui:WaitForChild("handler").Value.Value > 5 then
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, pass) then
local pet = game.ReplicatedStorage.Pets:FindFirstChild(petName, true)
if pet ~= nil then
local cloned = pet:Clone()
cloned.Parent = workspace.PlrPets:FindFirstChild(player.Name)
end
return "Equip"
end
elseif #game.Players:FindFirstChild(player.Name).PlayerGui:WaitForChild("handler").Value.Value == 8 then
return "UnEquip"
end
else
player:Kick("You have been kicked for exploiting")
end
end
Error
ServerScriptService.Pet Scripts.Script:6: attempt to get length of a number value