Hello! I created an idle timer, however, it isn’t working properly.
Expected behavior:
After 5 seconds of wait()
, while the player has been idle for 5 seconds, the timer will show. If the player does any input of any kind, it will hide the timer and put the clock at 0.
The problem:
The expected behavior would work around 1-4 times, but then after that, Roblox will think the player is idle after like 1 second of moving.
Video of problem:
The Code:
local timePassed = 0
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function()
script.Parent:TweenPosition(UDim2.new(0, 0, 1.2, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.2)
timePassed = 0
end)
uis.InputEnded:Connect(function()
while wait(1) do
timePassed += 1
if timePassed > 5 then
script.Parent:TweenPosition(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.2)
end
end
end)
If you can help, please let me know. Thanks, WE