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

Why doesnt there come any explosion after touch?

Asked by 2 years ago
script.Parent.Touched:Connect(function(hit)
        if hit ~= game.Workspace.Spawner then   -- the ~= means "Does not equal"
                    local EX = Instance.new("Explosion")
               EX.DestroyJointRadiusPercent = 0
                    EX.Position = script.Parent.Position
                    EX.BlastPressure = 10
                    EX.BlastRadius = 40
        EX.Hit:Connect(function(hit)
            if hit.Parent:FindFirstChild("Humanoid") ~= nil then
                hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2)
                    EX.Parent = script.Parent
            end
            end)

i def did something wrong but it doesnt show errors

1 answer

Log in to vote
0
Answered by 2 years ago

You have the script set the explosion to workspace when the explosion is hit. Explosions only explode when they are a descendant of workspace. You’d have to set it’s parent before the event.


EX.Position = script.Parent.Position EX.BlastPressure = 10 EX.BlastRadius = 40 EX.Parent = script.Parent EX.Hit:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then hit.Parent:FindFirstChild("Humanoid"):TakeDamage(2) end end)
0
yeah but how do i make it explode unless a part name is spawner thedukke1 9 — 2y
Ad

Answer this question