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

How to trigger a value to add by one? Help!

Asked by 7 years ago
Edited 7 years ago

For some reason the int Value "Hit" will not go up by one at all when "movenumber" gets to a certain position.

Help!

local movenumber = script.Parent
local Hit = script.Parent.MillisecondsOnesPlaceHitValue


while true do

wait(0.01)
movenumber.Position =  UDim2.new(0,0,0,0)
wait(0.01)
 movenumber.Position =  UDim2.new(0,-16,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-33,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-50,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-66,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-82,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-99,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-116,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-132,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-148,0,0)
wait(0.001)
movenumber.Position = UDim2.new(0,-160,0,0)
end 



if movenumber.Position == UDim2.new(0,-160,0,0)
    then Hit.Value = Hit.Value + 1
    end --this is not triggering, why exacty is it not triggering is my question?
0
Do you want a gui to move? Or just a value to add by one every time? User#16405 0 — 7y
0
to add by one every time. JoeRaptor 72 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Looking at your script, if you want the value hit to add one everytime the position of movenumber reaches a certain point is actually quite simple, your while loop continuously loops until a certain criteria is reached, but since you put while true do it will go forever.

Every time a while loop goes through it has to get from point A The start to point B The End therefore your if statement is not needed as the while loop will go through all the code from a to b so you can just add the hit.Value = hit.Value + 1 at the end like this:

local movenumber = script.Parent
local Hit = script.Parent.MillisecondsOnesPlaceHitValue


while true do

wait(0.01)
movenumber.Position =  UDim2.new(0,0,0,0)
wait(0.01)
 movenumber.Position =  UDim2.new(0,-16,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-33,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-50,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-66,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-82,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-99,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-116,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-132,0,0)
wait(0.01)
 movenumber.Position = UDim2.new(0,-148,0,0)
wait(0.001)
movenumber.Position = UDim2.new(0,-160,0,0)
Hit.Value = Hit.Value + 1
end 
Ad

Answer this question