Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with ClickDetector becoming a Parent..?

Asked by
Jiptix 2
8 years ago
Edited 8 years ago

Alright... I have this set up to where: Click Button>Explosion Happens>ClickDetector gets removed then re-added to the same place it was removed from(This is how I got it to have a 'reload time'). But the problem is, when the Click Detector gets re-added(line 20), it becomes a Parent of the actual script running all of this, which screws up the whole thing. Is there a different way to have a reload time or a way to make sure the re-added ClickDetector doesn't become a Parent of the script?

local
brickB = game.Workspace.ClickExplode.Brick1B  -- Change "Brick1B" to the name of whichever brick you want to explode when you press this button!

function onClicked()
   local e = Instance.new("Explosion") 
wait(1)  --Fuse, if you want an instant explosion, change the wait value to zero!

    e.BlastRadius = 10 

    e.BlastPressure = 1 

    e.Parent = script.Parent.Parent.Brick1B -- Change "Brick1B" to the name of whichever brick you want to explode when you press this button!

    e.Position = brickB.Position



    script.Parent.ClickDetector:remove()
    wait(3)
    script.Parent = Instance.new("ClickDetector", script.Parent.Parent.Brick1A)

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I am a noob, so some wording may be incorrect and whatnot. Surely someone understands my question. Thanks, Jip

0
You could use http://wiki.roblox.com/index.php?title=API:Class/ClickDetector/MaxActivationDistance which will disable the ability to click, then enable it after the wait. This would be better that deleting the click detetor each time. User#5423 17 — 8y

Answer this question