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

My AFK feature isn't working, anyone know what error I have made?

Asked by 5 years ago

local player = game.Players.LocalPlayer local character = game.Players.LocalPlayer.Character local playerfolder = game.Players.LocalPlayer:WaitForChild("playerfolder") local afk = playerfolder:WaitForChild("afk") local button = script.Parent

button.MouseButton1Click:Connect(function() afk.Value = not afk.Value local ff = Instance.new("ForceField") print(afk.Value) if afk.Value == true then ff.Parent = character wait(1200) ff:Destroy() player:kick('You have been AFK for longer than 20 mins') else ff:Destroy()
end end)

0
how do you expect anyone to be able to read it like that.. Bean_dinosaur 42 — 5y
0
Please don't just post a large block of code without any formatting, explanation, or context. Please include the output, put your code in a code block, correctly format it, mention things like if it's a local script or a server script, etc. Help us help you. vanilla_wizard 336 — 5y
0
Idented code posted as answer, hope it helps someone Leamir 3138 — 5y

1 answer

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Just Identing his code...

local player = game.Players.LocalPlayer 
local character = game.Players.LocalPlayer.Character 
local playerfolder = game.Players.LocalPlayer:WaitForChild("playerfolder") 
local afk = playerfolder:WaitForChild("afk") 
local button = script.Parent

button.MouseButton1Click:Connect(function() 
    afk.Value = not afk.Value 
    local ff = Instance.new("ForceField") 
    print(afk.Value) 
    if afk.Value == true then 
        ff.Parent = character 
        wait(1200) 
        ff:Destroy() 
        player:kick('You have been AFK for longer than 20 mins') 
    else 
        ff:Destroy()
    end 
end)

This is not the answer, just helping the ones that want to help

0
thank you for indenting it, "afk.Value = not afk.Value" immediately stood out vanilla_wizard 336 — 5y
0
upvoted User#19524 175 — 5y
Ad

Answer this question