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

Circle Bomb Script Won't Work?

Asked by 9 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:

01notBeenTouched = true
02wait(4)
03function onTouch(hit)
04    if notBeenTouched then 
05    NukeBall = Instance.new("Part", Workspace)
06    NukeBall.Shape = "Ball"
07    NukeBall.BrickColor = BrickColor.new("Deep orange")
08    NukeBall.CanCollide = false
09    notBeenTouched = false 
10    NukeBall.Anchored = true
11    for i = 5, 100, 5 do   
12    print(i)
13    NukeBall.Size = Vector3.new((i), (i) ,(i))         
14    wait(0.1)      
15    end
View all 23 lines...

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 18071 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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

01notBeenTouched = true
02-- Not sure why wait(4) was here
03function onTouch(hit)
04    if hit.Parent:FindFirstChild("Humanoid") then -- We want players to activate!
05        if notBeenTouched then 
06            notBeenTouched = false  -- We want this not to be spammed, so change notBeenTouched before anything else occurs
07            local NukeBall = Instance.new("Part", game.Workspace)
08            function onBombTouch(Hit)
09                Hit:BreakJoints()
10            end
11            NukeBall.Touched:connect(onBombTouch)
12            NukeBall.Shape = "Ball"
13            NukeBall.BrickColor = BrickColor.new("Deep orange")
14            NukeBall.CanCollide = false
15            NukeBall.Anchored = true
View all 30 lines...

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 — 9y
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 — 9y
Ad

Answer this question