Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script lowers the NumberValue, but I need the value to not go past 0. Help?

this is the script

local jetspeed = game.StarterGui.ScreenGui.StartJetBoots.wait

function clicked()
	jetspeed.Value = jetspeed.Value - 0.1
end

script.Parent.MouseButton1Down:Connect(clicked)

1 comment

0

use what i provided and mark it as solved. it's the most efficient way

2 answers

✓ Accepted answer
local jetspeed = game.Players.LocalPlayer.PlayerGui:WaitForChild('StartJetBoots'):WaitForChild('wait')
local min = 0
local max = math.huge


script.Parent.MouseButton1Down:Connect(function()
	jetspeed.Value = math.clamp(jetspeed.Value - 0.1, min, max)
end)

math.clamp doesn't allow a number to go under min, and doesnt allow the number to go over max. math.huge is infinite

i organized your script a little bit to prevent errors

1 comment

0

i had to fix the local jet speed but it works ty

i fixed the script nvm

its here if u need it too though

local jetspeed = game.StarterGui.ScreenGui.StartJetBoots.wait

function clicked()
	jetspeed.Value = jetspeed.Value - 0.1
	if jetspeed.Value < 0 then
		jetspeed.Value = 0
	end
end

script.Parent.MouseButton1Down:Connect(clicked)

1 comment

0

Please say [SOLVED] or something in the title

This discussion is preserved as it was. New answers, comments, and votes are closed.