Im setting the +4 Numbers every 1 seconds.
while task.wait(0.25) do
number += 1
end
How can i set +4 Numbers every 1 second but with task.wait(0,01)
, which number do i need to put to number += 1
Im setting the +4 Numbers every 1 seconds.
while task.wait(0.25) do
number += 1
end
How can i set +4 Numbers every 1 second but with task.wait(0,01)
, which number do i need to put to number += 1
Why would you need to do this?
while task.wait(0.01) do
number += 0.04
end
Because of this: I have a Train Game and the Sound can be in the Wrong Position if i want to get fast but task.wait(0.25) is not finished, then first the sound would start and then accleration
local runService = game:GetService("RunService")
local soundHoch = script.Parent.Hoch
local soundRunter = script.Parent.Runter
local number = 0
local hochOderRunter2
game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player, hochOderRunter)
hochOderRunter2 = hochOderRunter
if hochOderRunter == "Hoch" then
if soundHoch.TimePosition == 0 and soundRunter.TimePosition == 0 then
soundHoch:Play()
elseif soundRunter.TimePosition >= 5.2125 then
soundHoch.TimePosition = soundHoch.TimeLength - soundRunter.TimePosition
soundRunter:Stop()
soundHoch:Play()
else
soundHoch.TimePosition = 0 + soundRunter.TimeLength - soundRunter.TimePosition
print(soundHoch.TimePosition)
soundRunter:Stop()
soundHoch:Play()
end
elseif hochOderRunter == "Normal" then
elseif hochOderRunter == "Runter" then
if soundHoch.TimePosition >= 5.2125 then
soundRunter.TimePosition = soundRunter.TimeLength - soundHoch.TimePosition
soundHoch:Stop()
soundRunter:Play()
else
soundRunter.TimePosition = 0 + soundHoch.TimeLength - soundHoch.TimePosition
soundHoch:Stop()
soundRunter:Play()
end
end
end)
while task.wait(0.25) do
if hochOderRunter2 == "Hoch" then
if number < 80 then
number += 1
print(number)
end
elseif hochOderRunter2 == "Normal" then
print(number)
elseif hochOderRunter2 == "Runter" then
if number > 0 then
number -= 1
print(number)
end
end
end
I tried this but its not working with that
probably because it loops too fast or some other thing, change it to task.wait(0.05) or something
you can also do something like:
repeat
task.wait(1)
number +=4
until number = x
Thats the reverse of what i want to do
Its also not working
wasn’t the lowest task.wait time like 0.03?
This information helped me thanks
wait
is 1/30th of a second so roughly ~0.32…
task.wait
is 1/60th of a second so roughly ~0.16…
Both return as their first return value the amount of time yielded for, so you could do the following.
local num = 0
while true do
num += task.wait()
end
But i need that 4 Numbers going up in a second
Then multiply task.wait()
by 4.
local num = 0
while true do
num += (task.wait() * 4)
end
This is also not working i did this is this good?:
while task.wait(0.0303030303030303) do
number += 0.1212121212121212
end
If you want to increase a number by 4 every second then the snippet I’ve provided will work (I’ve tested).
While true gives me a Script timeout
The task.wait
yields the thread (preventing the timeout).
It goes up 2 numbers every seconds
local num1, num2 = 0, 0
while true do
local w = task.wait()
num1 += w
num2 += w * 4
print(num1, num2)
end
You should read up on task.wait
's documentation.