I’m a good scripter but I need help, with make a explosion like in “Trench Warfare” with the grenades that explode without damaging there teammate within range of the blast. I just need help or how I can achieve it.*
Never mind I found out how to make it so that a explosion doesn’t damage the team that threw it.
If anyone needs the code here you go (You need to edit it):
–// Services
local Players = game:GetService(“Players”)
local TeamsService = game:GetService(“Teams”)–// Spawn Functions
function SpawnExplosion()local Explosion = Instance.new(“Explosion”)
Explosion.BlastPressure = 500000
Explosion.BlastRadius = 8
Explosion.DestroyJointRadiusPercent = 0
Explosion.ExplosionType = Enum.ExplosionType.NoCraters
Explosion.Name = “NewExplosion”
Explosion.Parent = workspace
Explosion.Position = workspace.SpawnLocation.Positionreturn Explosion
end
–// Run
local NewExplosion = SpawnExplosion()–// Ignore Team
local TeamToIgnore = nil --// the Team–// Table of Hit
local AlreadyHit = {}–// Explosion has Touched Part
NewExplosion.Hit:Connect(function(Hit)local Player = Players:GetPlayerFromCharacter(Hit.Parent)
if Player and Player.Team ~= TeamToIgnore and not table.find(AlreadyHit, Player.Name) then
local Character = Player.Character local ExplosionPosition = NewExplosion.Position if (ExplosionPosition - Character.HumanoidRootPart.Position).Magnitude < 5 then Character.Humanoid.Health = 0 --// Damage else Character.Humanoid.Health -= 50 --// Damage end table.insert(AlreadyHit, Player.Name) --// Add to AlreadyHit Table
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.