IntValue returning 0 instead of set Default Value

I’m making a game where every second the player gains strength and this is my strength multiplier in the DataStore, the print() is returning the multiplierST.Value default as i set and expected (1), but from the strength giver script, and from the explorer it’s set to 0, how can i fix it?

My datastore:

local Multipliers = Instance.new("Folder") -- Sets up Multipliers folder

	Multipliers.Name = "Multipliers"

	Multipliers.Parent = player

	local multiplierST = Instance.new("IntValue")
	multiplierST.Name = "MultiplierST"
	multiplierST.Parent = Multipliers
	multiplierST.Value = 1
	print("MultiplierST Value:", multiplierST.Value)

My strength giver script:


local strengthAdd = 5 
local defenseAdd = 5
local healthIncrease = 2

while wait(1) do
		local char = player.Character
		if char then
			local humanoid = char:FindFirstChild("Humanoid")
			if humanoid then

			player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + (strengthAdd * player.Multipliers.MultiplierST.Value)
			player.leaderstats.Defense.Value = player.leaderstats.Defense.Value + defenseAdd

			humanoid.Health = player.leaderstats.Defense.Value + healthIncrease
			humanoid.MaxHealth = player.leaderstats.Defense.Value + healthIncrease
		end
	end
end

where is the Multipliers folder?

local Multipliers = Instance.new("Folder") -- Sets up Multipliers folder

	Multipliers.Name = "Multipliers"

	Multipliers.Parent = player

	
	local multiplierST = Instance.new("IntValue")
	
	multiplierST.Name = "MultiplierST"
	
	multiplierST.Parent = Multipliers
	
	multiplierST.Value = 1
	
	
	print("MultiplierST Value:", multiplierST.Value)

Sorry, i forgot to put it in

there isn’t math.round or any math functions, which is suspicious if you ask

There are no math.round or any math functions

that is exactly what I said, and it’s weird or some sort of script is changing the value to 0

in the pic it says 1 but the value is 0

Maybe the value is being set back to 0?
Try printing this:

print("MultiplierST Value:", multiplierST.Value)
task.wait(0.1)
print("MultiplierST Value:", multiplierST.Value)


Maybe a bug?

uhh contact @Bug-Support while you can?

Change it to NumberValue, it always work for me.

local Multipliers = Instance.new("Folder") -- Sets up Multipliers folder

	Multipliers.Name = "Multipliers"

	Multipliers.Parent = player

	local multiplierST = Instance.new("NumberValue")
	multiplierST.Name = "MultiplierST"
	multiplierST.Parent = Multipliers
	multiplierST.Value = 1
	print("MultiplierST Value:", multiplierST.Value)

Is the value 1 on the server still? Maybe it’s being set to 0 on the client instead. Or maybe the value is cloned on the client and it doesn’t replicate?

1 Like

Nop, even for the server the IntValue is 0

Well if it doesn’t go back after 0.1 seconds, maybe it’s not instantly. Try using this for debugging:

print("MultiplierST Value:", multiplierST.Value)
multiplierST.Changed:Connect(function()
	warn("MultiplierST Changed:", multiplierST.Value)
end)

Also, is there anywhere which is setting this value?

I tried and no sucess. It didn’t work either :confused:

issue4

So something is changing the value back, only on the server. Unfortunatly there’s no way to trace back what script indirectly triggered, to see what did it. Likely, it’s the script your working with or something else that uses the value. You should try to use Ctrl + Shift + F to find a value in all scripts. Try searching for the name of your int value, specially .Value with it as well.

Does it has a DataStore, if no, “ADD IT NOW!”, if yes, it’s a bug.

So, I’d say, it’s probably that it has no DataStore.

The Line that you need to add.

local DataStore = game:GetService:("DataStoreService"):GetDataStore("The Random Data")

Nothing setting it to 0 or nil