local leaderstats = Instance.new("Folder", pl)
leaderstats.Name = "leaderstats"
local Max = game.ReplicatedStorage.MaxValue.MaxValue
local food = Instance.new("IntValue", leaderstats)
food.Name = "Foods"
food.Value = 0
food.Changed:Connect(function(value)
if value > Max.Value then
food.Value = Max.Value
end
end)
local Money = Instance.new("IntValue", leaderstats)
Money.Name = "Money"
Money.Value = 0
end)
and the add max value script
local pl = game.Players.LocalPlayer
local leaderstats = pl.leaderstats
local Money = leaderstats.Money
local MaxValue = game.ReplicatedStorage.MaxValue.MaxValue
local price = 50
script.Parent.MouseButton1Click:Connect(function()
if Money.Value >= price then
Money.Value = Money.Value - price
MaxValue.Value = 30
end
end)
It looks to me as though the food value is somehow greater than 10 originally, and is being clamped whenever it tries to change. Try adding this at the end of the first script:
while true do
print(food)
wait()
end
If it is constantly printing a number greater than 10, then you will know that this is the issue.
game.Players.PlayerAdded:Connect(function(pl)
local leaderstats = Instance.new(“Folder”, pl)
leaderstats.Name = “leaderstats”
local Max = game.ReplicatedStorage.MaxValues.MaxValue
local food = Instance.new("IntValue", leaderstats)
food.Name = "Foods"
food.Value = 0
food.Changed:Connect(function(value)
if value > Max.Value then
food.Value = Max.Value
end
end)
local Money = Instance.new("IntValue", leaderstats)
Money.Name = "Money"
Money.Value = 0
while true do
print(food)
wait()
end