Heres what i want to know how do i make a script on a button like when i click it will do the events then i want to click the button again to revert the events
✓ ANSWER ACCEPTED
How to script a button that has 2 events?
1 answer
✓ Accepted answer
This is the simplest thing I could think of. Just change the script around to do what you want it to do, these are just the basics of doing and undoing with one button. If you need further help just ask, I'll reply asap.
script:
local Button = script.Parent
local status = 0 --1 = on (item spawned) , 0 = off (item is not spawned)
function spawnobject()
if status == 0 then
wait(1)
status = 1
local ball = Instance.new("Part")
ball.Parent = game.Workspace
ball.Position = Button.Position
ball.Shape = "Ball"
ball.Size = Vector3.new(5,5,5)
ball.Name = "SpawnedBall"
end
end
Button.ClickDetector.MouseClick:connect(spawnobject)
function despawnobject()
if status == 1 then
wait(1)
status = 0
game.Workspace:FindFirstChild("SpawnedBall"):Destroy()
end
end
Button.ClickDetector.MouseClick:connect(despawnobject)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Gridant, why not make it all under one single function?