Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited by raid6n 4 years ago

This question has been solved by the original poster.

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)
0
use what i provided and mark it as solved. it's the most efficient way iuclds 720 — 4y

2 answers

Log in to vote
2
Answered by
iuclds 720 Moderation Voter
4 years ago
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

0
i had to fix the local jet speed but it works ty GameStealerKid 79 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

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)
0
Please say [SOLVED] or something in the title WideSteal321 773 — 4y

Answer this question