Limiting stats to 50

i want to limit number value to 50

i have this script and tested it but its allowing me to get 51 which i should not be able to get

LIMIT NUMBER VALUE :slight_smile:

script.Parent.Triggered:Connect(function(plr)

	
	local Stars = plr:FindFirstChild("Quest"):WaitForChild("Stars")

	if Stars.Value < 50 then
		print(plr.Name)
		script.Parent.Parent:Destroy()
		Stars.Value += 1
		print(Stars.Value)
	end
end)

Use math.clamp(number,min,max) to achieve this.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.