Trying to Remove a Negative value In NumberValue

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

please help me

Anyway thank you!

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.

yes I know that, but it’s not what I need
Anyway thank you!

I Think you should use else return end or break Try something like that after if’s

I Try use break, but look :

1

Can you give all variables like where is the Pets and Data

Everthing is parented in players

Use IntValue , you can’t put decimals in it.

With IntValue the problem is you cant get higher then 9qn if i remember the max value of it

But i need to use decimals in it

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

use code block so it’s easier to read

thats script to increases the multiplier value in “Data” Folder

But there is no variable Named Data and Pets in it

Data.Multiplier1.Value = Data.Multiplier1.Value + v.Multiplier1.Value
Data.Multiplier2.Value = Data.Multiplier2.Value + v.Multiplier2.Value

v is the pet

Will you add at the top local Data = game.Players.LocalPlayer.Data

Yes,script :

local players = game:GetService(“Players”)
local plr = players.LocalPlayer
local Data = plr:WaitForChild(“Data”)

How are you adding the value of the Multiplier1?

by using the Multiplier1 In “Pets” Folder

I’m asking that how are you increasing the value of it?