So im making a script for a game and im new so i dont know this stuff but when i try to turn off my script instead of turning off it prints the turn off message but does not turn off can someone tell me why (@T3_MasterGamer help pls)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local on = false
script.Parent.MouseButton1Click:Connect(function()
if on == false then
print("turning on")
repeat
wait(1)
on = true
local part2 = Instance.new("Part", workspace)
part2.CanCollide = false
part2.Anchored = true
part2:PivotTo(character:WaitForChild("Head"):GetPivot() * CFrame.new(0, 0, 10))
part2.Name = "Part1"
character:WaitForChild("Humanoid"):MoveTo(part2.Position, part2)
until on == false
else
on = false
print("Turning off :(")
game.Workspace:WaitForChild("Part2"):Destroy()
script.Parent:Destroy()
end
end)

3 comments
what is your goal in this script?
anti afk
sorry i can't help i'm too confused :(