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

How would I add damage to this?

game.ReplicatedStorage.Event.OnServerEvent:connect(function(Player)
	local Character = Player.Character
	local Workspace = game.Workspace
	local random = math.random
	local Shapes = {"Ball", "Block", "Cylinder"}
		local Part = Instance.new('Part', Workspace)
	Part.Position = Character.Head.Position
	Part.Anchored = false
	Part.CanCollide = false
	Part.Elasticity = 10
	Part.BrickColor = Character.BasePlate.Outline.Color
	Part.Shape = Shapes[random(1,2)]
	Part.Material = "Neon"
	Part.Size = Vector3.new(1,1,1)
	Part.Velocity = Vector3.new(Character.Head.CFrame.lookVector.X * random(50,150), Character.Head.CFrame.lookVector.Y + random(10,25), Character.Head.CFrame.lookVector.Z * random(50,150))
	local Fire = Instance.new('Fire', Part)
	Fire.Color = Part.BrickColor.Color
	Fire.SecondaryColor = Fire.Color
	Fire.Heat = math.random(5,25)
	Fire.Size = math.random(2,10)
	local Light = Instance.new('PointLight',Part)
	Light.Color = Fire.Color
	Light.Brightness = random(1,4)
	Light.Range = random(10,45)
	Light.Shadows = true
	wait(1)
	local Pos = Instance.new('BodyPosition', Part)
	Pos.Position = Vector3.new(Part.Position.X, random(3,8), Part.Position.Z)
	wait(random(1,2))
	local Explosion = Instance.new('Part',Part)
	Explosion.Anchored = true
	Explosion.CanCollide = false
	Explosion.Size = Vector3.new(1,1,1)
	Explosion.BrickColor = Part.BrickColor
	Explosion.Position = Part.Position
	Explosion.Shape = Part.Shape
	Explosion.TopSurface = 'Smooth'
	Explosion.BottomSurface = 'Smooth'
	Explosion.Material = Enum.Material.Neon
	Explosion.Rotation = Vector3.new(random(-90,90),random(-90,90),random(-90,90))
	Explosion.Transparency = random(0,100) / 100
	repeat Explosion.Size = Vector3.new(Explosion.Size.X + 1, Explosion.Size.Y + 1, Explosion.Size.Z + 1) wait() until Explosion.Size == Vector3.new(55,55,55)
	wait(0.3)
	Part:Destroy()
end)

--I've tried making it damage the character it shoots from, that works. But I want it to hurt whomever is hit by the explosion. I tried a separate script and it inserts inside the explosion. The issue is the explosion has the issue: Parent is nil, and then the explosion makes the Part -As I dubbed in the script.- fly to the sky. Note: Explosion is only a Part named Explosion.

1 answer

✓ Accepted answer

You could loop all the players and then use magnitude on their character's torso to damage players within range.

http://wiki.roblox.com/index.php?title=Magnitude

5 comments

0

So, I'd basically make it so if the magnitude is a certain distance, they take damage? [Thus it'd leave possibility for damage intensifying?]

0

Yep.

0

Seems ideal. Thanks ^^;

0

If you were wondering. I just made it so the explosions fired all clients and the client script did the work from there.

0

i have a position magnitude example that i made for others to understand https://www.roblox.com/Position-Magnitude-example-item?id=397155349

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