How can I constrain my number value in between a few numbers?

I am trying to constrain my Number value between 1 and 15, and I have tried a math.clamp
script.Parent.Number.Value = math.clamp(1, 1, 15)
and this broke the script with no error. Here is the one of the scripts w/out math.clamp:
(The script runs off of two scripts, because there are two buttons; one to change the value up and one to change the value down. The other script is the exact same as below but with script.Parent.Number.Value-1)

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Number.Value = script.Parent.Number.Value+1
	script.Parent.Parent.ShirtNumber.Text = ""..script.Parent.Number.Value
end)

What do you mean by ‘broke the script with no error’? There seems to be something else causing that.

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Number.Value = math.clamp(script.Parent.Number.Value+1, 1, 15)
	script.Parent.Parent.ShirtNumber.Text = ""..script.Parent.Number.Value
end)

Just clamp is as per usual.

Believe I scripted it incorrectly; but I have the issue under control

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