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

Can someone tell me whats wrong with this car bomb script?

Asked by 9 years ago

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:

local currentBomb = "None"
local radius = 25
local multiplier = 3

script.Parent:WaitForChild("HasBomb")
script.Parent:WaitForChild("BombArmed")
script.Parent:WaitForChild("Essentials")
script.Parent.Essentials:WaitForChild("BombLight")

script.Parent.HasBomb.Changed:connect(function()
    if currentBomb == "None" then
        currentBomb = script.Parent.HasBomb.Value
        coroutine.resume(coroutine.create(function()
            while currentBomb ~= "None" do
                wait(2)
                script.Parent.Essentials.BombLight.Light.Enabled = true
                wait(0.2)
                script.Parent.Essentials.BombLight.Light.Enabled = false
            end
        end))
    elseif script.Parent.HasBomb.Value == "None" then
        currentBomb = "None"
    end
end)

script.Parent.BombArmed.Changed:connect(function()
    if currentBomb == "PrimeNRun" then
        for i = 1, 20 do
            script.Parent.Essentials.BombLight.Beep:Play()
            wait(1.4/i)
        end
        local e = Instance.new("Explosion",Workspace)
        e.Position = script.Parent:GetModelCFrame().p
        e.BlastPressure = 0
        e.BlastRadius = radius
        e.Hit:connect(function(part,dist)
            if part.Parent:FindFirstChild("HealthVal") and ((part.Name == "Primary" and part.Parent ~= script.Parent.Body) or part.Parent.Name == "") then              
                part.Parent.HealthVal.Value = part.Parent.HealthVal.Value - ((multiplier*2*radius/dist)^2.5)
            elseif game.Players:GetPlayerFromCharacter(part.Parent) then
                part.Parent.Humanoid:TakeDamage((multiplier*radius/dist)^1.5)
                if part.Parent.Humanoid.Health <= 0 and (not part.Parent.Humanoid:FindFirstChild("creator")) then
                    local tag = Instance.new("ObjectValue",part.Parent.Humanoid)
                    tag.Name = "creator"
                    tag.Value = script.Parent.OriginalOwner.Value
                    if script.Parent.OriginalOwner.Value:FindFirstChild("KillCounter") then
                        script.Parent.OriginalOwner.Value.KillCounter.Value = script.Parent.OriginalOwner.Value.KillCounter.Value + 1
                    end
                end
            end
        end)
        script.Parent:BreakJoints()
        game:GetService("Debris"):AddItem(script.Parent,10)
    elseif currentBomb == "Carsitting" then
        script.Parent.Essentials.VehicleSeat.ChildAdded:connect(function(kid)
            if kid.Name == "SeatWeld" then
                script.Parent.Essentials.BombLight.Beep:Play()
                wait(0.1)
                local e = Instance.new("Explosion",Workspace)
                e.Position = script.Parent:GetModelCFrame().p
                e.BlastPressure = 0
                e.BlastRadius = radius
                e.Hit:connect(function(part,dist)
                    if part.Parent:FindFirstChild("HealthVal") and ((part.Name == "Primary" and part.Parent ~= script.Parent.Body) or part.Parent.Name == "") then              
                        part.Parent.HealthVal.Value = part.Parent.HealthVal.Value - ((multiplier*2*radius/dist)^2.5)
                    elseif game.Players:GetPlayerFromCharacter(part.Parent) then
                        part.Parent.Humanoid:TakeDamage((multiplier*radius/dist)^1.5)
                        if part.Parent.Humanoid.Health <= 0 and (not part.Parent.Humanoid:FindFirstChild("creator")) then
                            local tag = Instance.new("ObjectValue",part.Parent.Humanoid)
                            tag.Name = "creator"
                            tag.Value = script.Parent.OriginalOwner.Value
                            if script.Parent.OriginalOwner.Value:FindFirstChild("KillCounter") then
                                script.Parent.OriginalOwner.Value.KillCounter.Value = script.Parent.OriginalOwner.Value.KillCounter.Value + 1
                            end
                        end
                    end
                end)
                game:GetService("Debris"):AddItem(script.Parent,10)
            end
        end)
    end
end)
0
Put your code within the block lua options. Not only does it make it easier for someone to answer your question as we dont have to download anything, But its also quicker than uploading something to another website to be downloaded. Uroxus 350 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

I am not even going to attempt to download this. Please use the lua code block and put your script in between the ~'s as it will make it look as an acctual script. I know it is hard to get used to, but please do it.

Ad

Answer this question