Been making a pet system for my game and for some odd reason it shows all the pets in the inventory as equipped anybody have a way to fix this?
It’s hard to give an answer without any script.
local EquippedPetsStrings = EquippedPetsSave:GetAsync(plr.UserId)
if EquippedPetsStrings ~= nil then
for i,v in pairs(EquippedPetsStrings) do
if game.ReplicatedStorage.PetIndex:FindFirstChild(tostring(v)) and PetsEquippedNumber.Value <= MaxPetsEquipped.Value then
local Pet = game.ReplicatedStorage.PetIndex:FindFirstChild(tostring(v)):Clone()
Pet.Parent = workspace.Player_Pets:FindFirstChild(plr.Name)
Pet.Equipped.Value = true
PetMultiplier.Value += Pet.Multiplier.Value
PetsEquippedNumber.Value += 1
end
end
end
the code above is the server script loads the pets into the player pets folder and follows them.
task.wait(4)
for i,v in pairs(plr.Pets:GetChildren()) do
if v:IsA("StringValue") then
local Pet = game.ReplicatedStorage.PetIndex[v.Name]
UpdatePlayersPets(Pet)
end
end
-----------
the code above fires 4 seconds after the server script and calls the function.
function UpdatePlayersPets(NewPet)
local cloendpet = NewPet:Clone()
local clonedTemplate = script.PetButtonUi:Clone()
if workspace.Player_Pets:WaitForChild(plr.Name):WaitForChild(cloendpet.Name).Equipped.Value == false then
clonedTemplate.Parent = script.Parent.PetInventoryFrame.Frame.innerFrame.PetButtonHolder
elseif workspace.Player_Pets:WaitForChild(plr.Name):WaitForChild(cloendpet.Name).Equipped.Value == true and plr.PetsEquippedIntTotal.Value <= plr.PetsEquippedNumber.Value then
print("No")
clonedTemplate:WaitForChild("Equipped").Value = true
clonedTemplate:WaitForChild("UIStroke").Color = Color3.fromRGB(80, 255, 61)
clonedTemplate:WaitForChild("TickIcon").Visible = true
clonedTemplate.Parent = script.Parent.PetInventoryFrame.Frame.innerFrame.PetButtonHolder
else
warn("Yes")
end
the code above is the function.
You are never setting the equipped indicator things to have their visibility set to false.
they are already set to false
this bit only fires if the equipped is true.