Hi I am trying to make a lag test game and I already have a button to add parts but I was thinking about automation but I cant figure out how to fix my script if you can help me please reply
local on = false if on == false and script.Parent.MouseButton1Click then on = true end if on == true and script.Parent.MouseButton1Click then on = false end if not on == false then local Part = Instance.new("Part") Part.Position = Vector3.new(-41, 0.5, 73) Part.Parent = game.Workspace.Folder Part.Name = "Hi" end
Here is the link to the game if you were wondering roblox.com/games/8482923831/lag-test-BE-CAREFUL
Thanks :)
Use the MouseButton1Click
event.
It is an event once a button is clicked.
local on = false script.Parent.MouseButton1Click:Connect(function() on = not on -- Set to the opposite of it's current value. if on then repeat wait local Part = Instance.new("Part") Part.Position = Vector3.new(-41, 0.5, 73) Part.Parent = game.Workspace.Folder Part.Name = "Hi" wait(1) until on == false end end)
You can use repeat wait until so that once on is set to true it makes a loop to make the part (again and again until it's not on).