Im trying to make it so that, you Equip The Pets, it increases the Multiplier value,And If You Unequipped The Multiplier reduced,but there some issue,Take a look at this video : https://www.youtube.com/watch?v=9FOn5h2N1oI
Equip Script :
local UiPetId = script.Parent.Parent.Parent.PetID.Value
for i,v in pairs(Pets:GetChildren()) do
if v.PetID.Value == UiPetId then
if v.Equipped.Value == true then
Data.Multiplier1.Value = Data.Multiplier1.Value + v.Multiplier1.Value
Data.Multiplier2.Value = Data.Multiplier2.Value + v.Multiplier2.Value
while wait() do
if Data.Multiplier1.Value < 0 then
Data.Multiplier1.Value = 0
elseif Data.Multiplier2.Value < 0 then
Data.Multiplier2.Value = 0
end
end
end
end
end
Unequip Script :
local UiPetId = script.Parent.Parent.Parent.PetID.Value
for i,v in pairs(Pets:GetChildren()) do
if v.PetID.Value == UiPetId then
if v.Equipped.Value == false then
Data.Multiplier1.Value = Data.Multiplier1.Value - v.Multiplier1.Value
Data.Multiplier2.Value = Data.Multiplier2.Value - v.Multiplier2.Value
while wait() do
if Data.Multiplier1.Value < 0 then
Data.Multiplier1.Value = 0
elseif Data.Multiplier2.Value < 0 then
Data.Multiplier2.Value = 0
end
end
end
end
end
You can use math.abs() to convert a negative number into a positive number as it returns the absolute value of it like print(math.abs(-10)) -- This will print 10.
local UiPetId = script.Parent.Parent.Parent.PetID.Value
for i,v in pairs(Pets:GetChildren()) do
if v.PetID.Value == UiPetId then
if v.Equipped.Value == true then
Data.Multiplier1.Value = Data.Multiplier1.Value + v.Multiplier1.Value
Data.Multiplier2.Value = Data.Multiplier2.Value + v.Multiplier2.Value
while wait() do
if Data.Multiplier1.Value < 0 then
Data.Multiplier1.Value = 0
elseif Data.Multiplier2.Value < 0 then
Data.Multiplier2.Value = 0
end
end
end
end
end
is this the code that is in the script or there is another variables