local UIS = game:GetService('UserInputService')
local TimeSinceLastInput = 0
UIS.InputBegan:Connect(function()
TimeSinceLastInput = 0
end)
while true do
TimeSinceLastInput += task.wait() -- task.wait() returns a number and still waits even if you use it as a number.
if TimeSinceLastInput > 120 then
-- do something
end
end
local UIS = game:GetService('UserInputService')
local TimeSinceLastInput = 0
local image = script.Parent
image.ImageTransparency = 1
UIS.InputBegan:Connect(function()
TimeSinceLastInput = 0
end)
while true do
TimeSinceLastInput += task.wait() -- task.wait() returns a number and still waits even if you use it as a number.
if TimeSinceLastInput > 10 then
image.ImageTransparency = 0.8
task.wait(0.25)
image.ImageTransparency = 1
task.wait(0.25)
image.ImageTransparency = 0.8
wait(0.25)
image.ImageTransparency = 1
task.wait(1)
image.ImageTransparency = 0.5
task.wait(0.25)
image.ImageTransparency = 1
task.wait(0.25)
image.ImageTransparency = 0.5
wait(0.25)
image.ImageTransparency = 1
task.wait(1)
image.ImageTransparency = 0.2
task.wait(0.25)
image.ImageTransparency = 1
task.wait(0.25)
image.ImageTransparency = 0.2
wait(0.25)
image.ImageTransparency = 1
task.wait(1)
end
end
How do I make the image dissappear and stop appearing if the player moves again?
You could use a different method which is UserInputService.WindowFocused. It checks if the Roblox client is focused on the computer. UserInputService.WindowFocusReleased works oppositely, it checks if the window is unfocused.
Thanks, but I’m trying to make a horror game where if you don’t move then text will come up on your screen saying MOVE until it jumpscares you, so that’s not rlly what I’m going for but thanks.
local Player = game.Players.LocalPlayer --local player
repeat wait(1) until Player.Character --repeats wait(1) until the character has loaded
local Character = Player.Character --character
local image = script.Parent
local move = false
local Humanoid = Character:FindFirstChild("Humanoid") --finds the humanoid from the players character
local RunService = game:GetService("RunService") --run service
local function IsPlayerMoving() --function
if Humanoid.MoveDirection.Magnitude == 0 then --if the movedirection is equal to 0 then the following will happen;
move = false
task.wait(5)
print("no")
task.wait(0.2)
image.ImageTransparency = 0.8
task.wait(0.2)
image.ImageTransparency = 1
task.wait(0.2)
image.ImageTransparency = 0.8
task.wait(0.2)
image.ImageTransparency = 1
task.wait(1)
image.ImageTransparency = 0.5
task.wait(0.2)
image.ImageTransparency = 1
task.wait(0.2)
image.ImageTransparency = 0.5
task.wait(0.2)
image.ImageTransparency = 1
task.wait(1)
image.ImageTransparency = 0.3
task.wait(0.2)
image.ImageTransparency = 1
task.wait(0.2)
image.ImageTransparency = 0.3
task.wait(0.2)
image.ImageTransparency = 1
task.wait(1)
image.ImageTransparency = 0.2
task.wait(0.2)
image.ImageTransparency = 1
task.wait(0.2)
image.ImageTransparency = 0.2
task.wait(1)
if move == false then
Player:Kick("AFK")
end
elseif Humanoid.MoveDirection.Magnitude > 0 then --if the movedirection is greater than 0 then the following will happen;
image.ImageTransparency = 1
move = true
end
end
RunService.RenderStepped:Connect(IsPlayerMoving) --running the function