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

[ANSWERED] Made a script that kicks you after 30 mins of idle, anything wrong?

Asked by 3 years ago
Edited 3 years ago

Script:

local count = 0
local player = script.Parent.Parent
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local beginTimer = false

humanoid.Running:Connect(function(speed)
    if speed > 0 then
        count = 0
        beginTimer = false
        print("Moving!")
    elseif speed == 0 then
        beginTimer = true
        print("Stopped!")
    end
end)

while true do
    wait(1)
    if beginTimer == true then
        count += 1
        print("Count: ", count)
        if count == 10 then
            player:Kick("You were kicked for being idle 30+ minutes.")
        end
    end
end

By the way I reduced the numbers for testing. I got the error: Players.RedstonePlayz09.PlayerScripts.IdleKickScript:4: attempt to index nil with 'WaitForChild' (This is a script inside a StarterPlayerScripts)

0
do local character = player.Character or player.CharacterAdded:Wait() and local humanoid = character:FindFirstChild("Humanoid") OhManXDXD 445 — 3y
0
Thanks it worked! RedstonePlayz09 0 — 3y

Answer this question