I wish to create a building system where when the player presses a button it places a model, though I would also like it so when the player presses a different button it replaced the model which was set from the previous button. Currently, when a player clicks a button it runs the placement function with the button name, which allows the player to place a model when they click on a suitable area. How do I cancel the ‘placeStructure’ function after a new button is pressed?. I am unsure of how to do this, Could someone please give me some help?
Current button/model selector script:
for i, Button in pairs(script.Parent.Buttons.Frame:GetChildren())do
if Button:IsA("TextButton")then
Button.MouseButton1Up:Connect(function()
local structure = Button.Name
placeStructure(structure)
end)
end
end