I'm trying to the player have a cap limit to the amount of currency they can have/ They can't go beyond a certain point.

For Example, if the player's Currency goes over 10 then the Currency won't change.

I tried doing this but my script doesn't seem to work?

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"

	local folder = Instance.new("Folder",plr)
	folder.Name = "ValueHolder"
	
	local Coins = Instance.new("NumberValue", leaderstats)
	Coins.Name = "Coins"
	Coins.Value = 0
	
	local Leaf = Instance.new("IntValue", leaderstats)
	Leaf.Name = "Leaf"
	Leaf.Value = 10
	
	local MaxLeaf = Instance.new("IntValue", folder)
	MaxLeaf.Name = "MaxLeaf"
	MaxLeaf.Value = 25
	
	local BagFull = Instance.new("BoolValue", folder)
	BagFull.Value = false
	
	local Ranks = Instance.new("StringValue", leaderstats)
	Ranks.Name = "Rank"
	
	Leaf.Changed:connect(function()
		if Leaf.Value >= MaxLeaf.Value then
			Leaf.Value = MaxLeaf.Value
			BagFull = true
			print("Players Bag Is Full!")
		else
			BagFull = false
		end
	end)
	
		
end)

2 comments

0

Figured it out :

0

This won't fix it but, use :Connect() not :connect().