My script is not getting the correct leaderstat value

The value of my leaderstat is 10 million but apparently thats less than 200

if player.leaderstats.Money.Value < 200 then
						game.ReplicatedStorage.error:FireClient(player)
					else
						player.leaderstats.Money.Value -= 200
						script.Parent.ParticleEmitter.Enabled = true
						player.HiddenStats.p1lvl.Value = 2
						local ep = game.ServerStorage.Presents.Tycoon1.Pos1.Level2:Clone()
						script.Parent.Parent.Parent.Parent.Parent.Presents.p1:ClearAllChildren()
						ep.Parent = script.Parent.Parent.Parent.Parent.Parent.Presents.p1
						script.Parent.BillboardGui.Price.Text = "$1,500"
						wait(1)
						script.Parent.ParticleEmitter.Enabled = false
					end
1 Like

Are you sure you changed your “money” from the server side? everything seems fine.

2 Likes

yeah I’m so confused. I tried switching the < to > and it still fired the error event.

Maybe it’s coming from another script.

there is no other script that checks the value

Have you checked to make sure your money value is above 200? Try printing the Money Value to see the exact value you have.

print(player.leaderstats.Money.Value)

it doesn’t even print anything. How should I go about fixing this

Was there any errors in the output when you tried printing it? Also, you should be printing the value in that same script you have given in your post, just above the if statement.

no errors and i did place it above

Is the leader stats value replicating on the client or server?

on the sevrer
-------character limit

If that’s the case, then I believe either the code you have given doesn’t run, or there is another script that fires the same remote event. If possible, could you please show your entire script to have a better understanding of what the issue could be?

Where are you getting player from?

local db = true
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			script.Parent.CanTouch = false
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if player.Name == script.Parent.Parent.Parent.Parent.Parent.Parent.Owner.Value then
				if player.HiddenStats.p1lvl.Value == 0 then
					print("eeeeee")
					if player.leaderstats.Money.Value >= script.Parent.BillboardGui.PriceMoney.Value then
						script.Parent.ParticleEmitter.Enabled = true
						player.leaderstats.Money.Value -= script.Parent.BillboardGui.PriceMoney.Value
						player.HiddenStats.p1lvl.Value = 1
						local ep = game.ServerStorage.Presents.Tycoon1.Pos1.Level1:Clone()
						script.Parent.Parent.Parent.Parent.Parent.Presents.p1:ClearAllChildren()
						ep.Parent = script.Parent.Parent.Parent.Parent.Parent.Presents.p1
						script.Parent.Color = Color3.new(0,.5,1)
						script.Parent.BillboardGui.Price.Text = "$200"
						script.Parent.BillboardGui.Item.Text = "Upgrade"
						wait(1)
						script.Parent.ParticleEmitter.Enabled = false
					else
						game.ReplicatedStorage.error:FireClient(player)
					end	
				elseif player.HiddenStats.p1lvl == 1 then
					print(player.leaderstats.Money.Value)
					if player.leaderstats.Money.Value < 200 then
						game.ReplicatedStorage.error:FireClient(player)
					else
						player.leaderstats.Money.Value -= 200
						script.Parent.ParticleEmitter.Enabled = true
						player.HiddenStats.p1lvl.Value = 2
						local ep = game.ServerStorage.Presents.Tycoon1.Pos1.Level2:Clone()
						script.Parent.Parent.Parent.Parent.Parent.Presents.p1:ClearAllChildren()
						ep.Parent = script.Parent.Parent.Parent.Parent.Parent.Presents.p1
						script.Parent.BillboardGui.Price.Text = "$1,500"
						wait(1)
						script.Parent.ParticleEmitter.Enabled = false
					end
				elseif player.HiddenStats.p1lvl == 2 then
					if player.leaderstats.Money.Value >= 1500 then
						player.leaderstats.Money.Value -= 1500
						script.Parent.ParticleEmitter.Enabled = true
						player.HiddenStats.p1lvl.Value = 3
						local ep = game.ServerStorage.Presents.Tycoon1.Pos1.Level3:Clone()
						script.Parent.Parent.Parent.Parent.Parent.Presents.p1:ClearAllChildren()
						ep.Parent = script.Parent.Parent.Parent.Parent.Parent.Presents.p1
						script.Parent.BillboardGui.Price.Text = "$17,500"
						wait(1)
						script.Parent.ParticleEmitter.Enabled = false
					else
						game.ReplicatedStorage.error:FireClient(player)
					end
				elseif player.HiddenStats.p1lvl == 3 then
					if player.leaderstats.Money.Value >= 17500 then
						player.leaderstats.Money.Value -= 17500
						script.Parent.ParticleEmitter.Enabled = true
						player.HiddenStats.p1lvl.Value = 4
						local ep = game.ServerStorage.Presents.Tycoon1.Pos1.Level4:Clone()
						script.Parent.Parent.Parent.Parent.Parent.Presents.p1:ClearAllChildren()
						ep.Parent = script.Parent.Parent.Parent.Parent.Parent.Presents.p1
						script.Parent.BillboardGui.Price.Text = "$100,000"
						wait(1)
						script.Parent.ParticleEmitter.Enabled = false
					else
						game.ReplicatedStorage.error:FireClient(player)
					end
				elseif player.HiddenStats.p1lvl == 4 then
					if player.leaderstats.Money.Value >= 100000 then
						player.leaderstats.Money.Value -= 100000
						script.Parent.ParticleEmitter.Enabled = true
						player.HiddenStats.p1lvl.Value = 5
						local ep = game.ServerStorage.Presents.Tycoon1.Pos1.Level5:Clone()
						script.Parent.Parent.Parent.Parent.Parent.Presents.p1:ClearAllChildren()
						ep.Parent = script.Parent.Parent.Parent.Parent.Parent.Presents.p1
						script.Parent.Color = Color3.new(1,0,0)
						script.Parent.BillboardGui.Price.Text = "lvl max"
						wait(1)
						script.Parent.ParticleEmitter.Enabled = false
					else
						game.ReplicatedStorage.error:FireClient(player)
					end
				else
					game.ReplicatedStorage.error:FireClient(player)
				end
			end
			wait(1)
			db = true
			script.Parent.CanTouch = true
		end
	end	
end)

Can you share the Roblox Studio place for us please?

Does it print the player if you add a print after local player?

yes
Character Limit eeeeeeeeeeeeeee

can u show what the output looks like?