Hello! I’ve made this boxes, that inside them there’s a ClickDetector and a Script
that when the player click on it, it is destroyed, and the click detector of the other boxes are “disabled” and it able the player to place the boxes in the select location:
And to make it work again, when the player places the box, the ClickDetectors of the boxes that remain, are enabled again. By this script:
local box1 = game.Workspace.MissionsStuff.Chanching.BedBox local box2 = game.Workspace.MissionsStuff.Chanching.DownstairsBox local box3 = game.Workspace.MissionsStuff.Chanching.EntranceBox local box4 = game.Workspace.MissionsStuff.Chanching.GarageBox local box5 = game.Workspace.MissionsStuff.Chanching.KitchenBox local box6 = game.Workspace.MissionsStuff.Chanching.OfficeBox1 local box7 = game.Workspace.MissionsStuff.Chanching.OfficeBox2 local box8 = game.Workspace.MissionsStuff.Chanching.RoomBox function onClicked() game.ReplicatedStorage.MissionStuff.Chanching.BoxesClosed.OfficeBox1:Clone().Parent = game.Workspace.MissionsStuff.Chanching wait() script.Parent:Destroy() box1.ClickDetector.MaxActivationDistance = 4 box2.ClickDetector.MaxActivationDistance = 4 box3.ClickDetector.MaxActivationDistance = 4 box4.ClickDetector.MaxActivationDistance = 4 box5.ClickDetector.MaxActivationDistance = 4 box6.ClickDetector.MaxActivationDistance = 4 box7.ClickDetector.MaxActivationDistance = 4 box8.ClickDetector.MaxActivationDistance = 4 end script.Parent.ClickDetector.MouseClick:connect(onClicked)
The problem here, is that one of the variables that I’ve created, doesn’t exist anymore. Because I’ve destroyed it. So how can I make the other click detectors start working again?
I’ve tried using what I think is a table:
local clickDetectors = {}; table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.BedBox.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.DownstairsBox.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.EntranceBox.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.GarageBox.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.KitchenBox.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.OfficeBox1.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.OfficeBox2.ClickDetector) table.insert(clickDetectors, game.Workspace.MissionsStuff.Chanching.RoomBox.ClickDetector) function onClicked() game.ReplicatedStorage.MissionStuff.Chanching.BoxesClosed.OfficeBox1:Clone().Parent = game.Workspace.MissionsStuff.Chanching wait() script.Parent:Destroy() clickDetectors.MaxActivationDistance = 4 end script.Parent.ClickDetector.MouseClick:connect(onClicked)
But the script still brokes.