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

Textbutton not running script after clicking the second time?

local a = 0
local P = Instance.new("Part", game.Workspace)

script.Parent.MouseButton1Click:Connect(function()
repeat
a = a + 1
P.Size = Vector3.new(50,50,50)
P.Position = Vector3.new(0,0,0)
P.Anchored = true
P.Transparency = 1
print("test")
until a >= 5000
P:Destroy()
end)

This is my script to lag people for fun. Its inside a local script and the parent of the local script is a textbutton. The problem is that when I click it once its alright but it doesnt run the script when I click it the second time. Not sure what is wrong with my script , please help thank you.

1 answer

Move "local a = 0" into the function before the "repeat" part. This redefines your "a" value to "0" and means that it will start counting up to 5000 again rather than going by 1 then destroying the part almost immediately.

Edit: You should do this for your "instance.new" part as well because then it would call out to a part that was destroyed instead of a fresh and new one!

If you have any questions or issues contact me. ;)

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