Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Non-team killing explosion script not working?

This script is supposed to create an explosion, and kill any members of enemy teams, without causing an actual explosion (that would destroy/kill anything, regardless of team) occurring.

The script doesn't do anything, and I don't know why. Output didn't give me anything.

Can someone please help me?

Here's the script:

local activated = false
local mash = math.random(20,30)

function Hurt(hit)
    if hit.Parent then
        if hit.Parent:findFirstChild("Humanoid") then
            local Person = script.Parent:findFirstChild("creator")
            local victim = game.Players:findFirstChild(hit.Parent.Name)
            if victim ~= Person.Value and victim.TeamColor ~= Person.Value.TeamColor then
                local New = 300
                local ct=script.Parent:FindFirstChild("creator")
                ct:clone().Parent = hit.Parent.Humanoid
                wait(0.01)
                hit.Parent.Humanoid:TakeDamage(New)
            end
        end
    end
end

function onTouch(hit)
	if not activated then
		script.Parent.Transparency = 1
		script.Parent.Anchored = true
		activated = true
		local sound = Instance.new("Sound")
		sound.SoundId = "http://www.roblox.com/asset/?id=16976189"
		sound.Pitch = .9
		sound.Volume = 1
		sound.Parent = script.Parent
		sound:Play()
		local e = Instance.new("Explosion")
		e.BlastPressure = 0
		e.BlastRadius = 60
		e.Parent = game.Workspace
		e.Hit:connect(Hurt)
		e.Position = script.Parent.Position
		script.Parent:remove()
	end
end

script.Parent.Touched:connect(onTouch)

1 answer

Sorry that this comment may be a bit late.

local activated = false
local mash = math.random(20,30)

function Hurt(hit)
    if hit.Parent and hit.Parent:FindFirstChild('Humanoid') then
            local Person = game.Players:GetPlayerFromCharacter(script.Parent:findFirstChild("creator").Value)
	    local victim = game.Players:GetPlayerFromCharacter(hit.Parent)
            if victim.Name ~= Person.Name and victim.TeamColor ~= Person.TeamColor then
                local damage = 300
                local ct=script.Parent:FindFirstChild("creator")
                ct:clone().Parent = hit.Parent.Humanoid
                wait(0.01)
                hit.Parent.Humanoid:TakeDamage(damage)
        end
    end
end


script.Parent.Touched:connect(function(hit)
    if not activated then
        script.Parent.Transparency = 1
        script.Parent.Anchored = true
        activated = true
        local sound = Instance.new("Sound")
        sound.SoundId = "http://www.roblox.com/asset/?id=16976189"
        sound.Pitch = .9
        sound.Volume = 1
        sound.Parent = script.Parent
        sound:Play()
        local e = Instance.new("Explosion")
        e.BlastPressure = 0
        e.BlastRadius = 60
        e.Parent = game.Workspace
        e.Hit:connect(Hurt)
        e.Position = script.Parent.Position
        script.Parent:remove()
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.