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

Why is my code being printed from bottom to top?

Asked by
2mania 14
2 years ago

Im making a anti afk script for my game so players dont get kicked it works and all but why does it read from top to bottom?

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()



local on = true


script.Parent.MouseButton1Click:Connect(function()
    if on == true then
    repeat
        print("I am on")
        wait(2)
        local part2 = Instance.new("Part", workspace)
        part2.CanCollide = false
        part2.Anchored = true
        part2.Transparency = 1
        part2:PivotTo(character:WaitForChild("Head"):GetPivot() * CFrame.new(0, 0, 20))
        part2.Name = "Part1"

        character:WaitForChild("Humanoid"):MoveTo(part2.Position, part2)
        until on == false


    end

end)

script.Parent.Parent.stop.MouseButton1Click:Connect(function()
    on = false
    print("Off")
end)
script.Parent.MouseButton1Click:Connect(function()
    on = true
    print("On")
end)

0
What exactly do you mean "printed bottom to top"? If it's printing Off/On _before_ "I am on", then it's most likely just recognizing those two before the first print since they don't have an 'if' condition, otherwise if you mean it's "I am on" and then "Off"/"On", that's just how roblox scripts work normally, from top to bottom Alley_Blossom 45 — 1y

Answer this question