I have a part that when it touches another part or object it explodes but the explosion happens in the middle of the base plate and not on the part, help!
function onTouch(hit) local f=Instance.new("Explosion") f.Parent=script.Parent f.BlastPressure=500 f.BlastRadius=500 end script.Parent.Touched:connect(onTouch)
Simple, just set the position of the explosion to the part's position.
f.Position=script.Parent.Position
Full script:
function onTouch() --We won't need any arguments here. Just making an explosion. local f=Instance.new("Explosion", script.Parent) --A shortcut to setting the explosion's Parent. f.BlastPressure=500 f.BlastRadius=500 f.Position=script.Parent.Position end script.Parent.Touched:connect(onTouch)
The above persons script makes sense since the explosion will occur at the scripts parents position, but they still need debounce.
--First of all, debounce is just a variable, it's just a name for how we're using the variable. --Debounce doesn't need to be named "debounce" it could be named anything! --Ex: "thisisanokayname" "db" "wow" --I'm going to use "db" db = true -- make db true function onTouch() if db then -- if db is true then continue with the script db = false -- set db to false so if the function is called before the function runs through all the way, it stops at the previous line local f=Instance.new("Explosion", script.Parent) f.BlastPressure=500 f.BlastRadius=500 f.Position=script.Parent.Position wait(.5) db = true -- now the function can run again because db = true end end script.Parent.Touched:connect(onTouch)