New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

# Circle Bomb Script Won't Work?

Asked by 4 years ago

Hey guys, This is my first post so if there is any etiquette I need to take care of I do not know yet. But enough about that, onto my question. I am making a bomb that is generated when you step on a plate. After stepping, the bomb/nuke will generate as a circle and expand. Anything that touches will have BreakJoints() applied. My script is below:

notBeenTouched = true
wait(4)
function onTouch(hit)
if notBeenTouched then
NukeBall = Instance.new("Part", Workspace)
NukeBall.Shape = "Ball"
NukeBall.BrickColor = BrickColor.new("Deep orange")
NukeBall.CanCollide = false
notBeenTouched = false
NukeBall.Anchored = true
for i = 5, 100, 5 do
print(i)
NukeBall.Size = Vector3.new((i), (i) ,(i))
wait(0.1)
end
NukeBall.Transparency = 0.5
wait(0.5)
NukeBall.Transparency = 1
NukeBall:remove()
end
end

script.Parent.Touched:connect(onTouch)


How can I apply the detection for knowing if the bomb is touched and break joints? It would be greatly appreciated. Thanks all!

0
Edited to fix code formatting. BlueTaslem 17801 — 4y

### 1 answer

Log in to vote
0
Answered by 4 years ago

First, I tabbed your code. Look bellow for finished code:

notBeenTouched = true
-- Not sure why wait(4) was here
function onTouch(hit)
if hit.Parent:FindFirstChild("Humanoid") then -- We want players to activate!
if notBeenTouched then
notBeenTouched = false  -- We want this not to be spammed, so change notBeenTouched before anything else occurs
local NukeBall = Instance.new("Part", game.Workspace)
function onBombTouch(Hit)
Hit:BreakJoints()
end
NukeBall.Touched:connect(onBombTouch)
NukeBall.Shape = "Ball"
NukeBall.BrickColor = BrickColor.new("Deep orange")
NukeBall.CanCollide = false
NukeBall.Anchored = true
for i = 5, 100, 5 do
print(i)
NukeBall.Size = Vector3.new((i), (i) ,(i))
wait(0.1)
end
NukeBall.Transparency = 0.5
wait(0.5)
NukeBall.Transparency = 1
NukeBall:remove()
notBeenTouched = true -- Lets this function Again
end
end
end

script.Parent.Touched:connect(onTouch)


Now, You need to place your explosion somewhere, this script doesn't seem to do that! First, when the NukeBall is created, we want to make a touched event connected to that, so after it was made, I began the function. Now, you want to start the listening of this event (When you use :connect) before the size is expanded, if not, anything touching during that expansion will be unaffected! Not quite what you'd want. At the end, I made your variable notBeenTouched true again, this will make the script run another time after the nuke is complete. Remove this variable's change to true if you do not want it to occur again!

Comment if you have questions! Otherwise, toss a +1 rep if this helps!

0
Hey, yoman1776 85 — 4y
0
Sorry about that, accidentally pressed enter. Anyways, this fixed my oroblem completely. Thanks SO much, I honestly couldn't be more greatful. I can't drop a rep, but I just want to show my gratitude here. Thanks again! yoman1776 85 — 4y