Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

3 comments

0

how do you expect anyone to be able to read it like that..

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.

0

Idented code posted as answer, hope it helps someone

1 answer

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

2 comments

0

thank you for indenting it, "afk.Value = not afk.Value" immediately stood out

0

upvoted

This discussion is preserved as it was. New answers, comments, and votes are closed.