Can someone tell me whats wrong with this car bomb script?
I am making a new game that has cars that are placed into lighting, then when a user clicks the pad he chooses which car he wants. I have the car spawning and driving working, but when I go to the bomb shop and put a bomb in my car and then activate the bomb, it makes the bomb blinking light and explosion near the place the car spawned. My goal is to get it to explode exactly where the player is sitting so he dies. Can someone take a look at the script and find out why it is placeing the explosion and blinking light where the car spawned? Here is the script:
01 | local currentBomb = "None" |
05 | script.Parent:WaitForChild( "HasBomb" ) |
06 | script.Parent:WaitForChild( "BombArmed" ) |
07 | script.Parent:WaitForChild( "Essentials" ) |
08 | script.Parent.Essentials:WaitForChild( "BombLight" ) |
10 | script.Parent.HasBomb.Changed:connect( function () |
11 | if currentBomb = = "None" then |
12 | currentBomb = script.Parent.HasBomb.Value |
13 | coroutine.resume(coroutine.create( function () |
14 | while currentBomb ~ = "None" do |
16 | script.Parent.Essentials.BombLight.Light.Enabled = true |
18 | script.Parent.Essentials.BombLight.Light.Enabled = false |
21 | elseif script.Parent.HasBomb.Value = = "None" then |
26 | script.Parent.BombArmed.Changed:connect( function () |
27 | if currentBomb = = "PrimeNRun" then |
29 | script.Parent.Essentials.BombLight.Beep:Play() |
32 | local e = Instance.new( "Explosion" ,Workspace) |
33 | e.Position = script.Parent:GetModelCFrame().p |
35 | e.BlastRadius = radius |
36 | e.Hit:connect( function (part,dist) |
37 | if part.Parent:FindFirstChild( "HealthVal" ) and ((part.Name = = "Primary" and part.Parent ~ = script.Parent.Body) or part.Parent.Name = = "" ) then |
38 | part.Parent.HealthVal.Value = part.Parent.HealthVal.Value - ((multiplier* 2 *radius/dist)^ 2.5 ) |
39 | elseif game.Players:GetPlayerFromCharacter(part.Parent) then |
40 | part.Parent.Humanoid:TakeDamage((multiplier*radius/dist)^ 1.5 ) |
41 | if part.Parent.Humanoid.Health < = 0 and ( not part.Parent.Humanoid:FindFirstChild( "creator" )) then |
42 | local tag = Instance.new( "ObjectValue" ,part.Parent.Humanoid) |
44 | tag.Value = script.Parent.OriginalOwner.Value |
45 | if script.Parent.OriginalOwner.Value:FindFirstChild( "KillCounter" ) then |
46 | script.Parent.OriginalOwner.Value.KillCounter.Value = script.Parent.OriginalOwner.Value.KillCounter.Value + 1 |
51 | script.Parent:BreakJoints() |
52 | game:GetService( "Debris" ):AddItem(script.Parent, 10 ) |
53 | elseif currentBomb = = "Carsitting" then |
54 | script.Parent.Essentials.VehicleSeat.ChildAdded:connect( function (kid) |
55 | if kid.Name = = "SeatWeld" then |
56 | script.Parent.Essentials.BombLight.Beep:Play() |
58 | local e = Instance.new( "Explosion" ,Workspace) |
59 | e.Position = script.Parent:GetModelCFrame().p |
61 | e.BlastRadius = radius |
62 | e.Hit:connect( function (part,dist) |
63 | if part.Parent:FindFirstChild( "HealthVal" ) and ((part.Name = = "Primary" and part.Parent ~ = script.Parent.Body) or part.Parent.Name = = "" ) then |
64 | part.Parent.HealthVal.Value = part.Parent.HealthVal.Value - ((multiplier* 2 *radius/dist)^ 2.5 ) |
65 | elseif game.Players:GetPlayerFromCharacter(part.Parent) then |
66 | part.Parent.Humanoid:TakeDamage((multiplier*radius/dist)^ 1.5 ) |
67 | if part.Parent.Humanoid.Health < = 0 and ( not part.Parent.Humanoid:FindFirstChild( "creator" )) then |
68 | local tag = Instance.new( "ObjectValue" ,part.Parent.Humanoid) |
70 | tag.Value = script.Parent.OriginalOwner.Value |
71 | if script.Parent.OriginalOwner.Value:FindFirstChild( "KillCounter" ) then |
72 | script.Parent.OriginalOwner.Value.KillCounter.Value = script.Parent.OriginalOwner.Value.KillCounter.Value + 1 |
77 | game:GetService( "Debris" ):AddItem(script.Parent, 10 ) |