Maing an explosion where part was touched?
Asked by
8 years ago Edited 8 years ago
So i made this script that is saposed to make an explosion effect wherever the 2 parts collide
I have an on touched script that clones the following script into whatever is touching the part, in this case a players body part, whenever you or a npc touches the player an explosion part will appear whereever the 2 parts touched
The problem is that sometimes when i touch another humanoid the explosions would appear over my should if something were to touch on of my legs
01 | local ExplosionPart = Instance.new( 'Part' ,workspace) |
02 | ExplosionPart.CFrame = script.Parent.CFrame |
03 | ExplosionPart.Anchored = true |
04 | ExplosionPart.CanCollide = false |
05 | ExplosionPart.Size = Vector 3. new( 1 , 1 , 1 ) |
06 | ExplosionPart.BrickColor = BrickColor.new( 'Really black' ) |
07 | ExplosionPart.Material = 'Neon' |
08 | ExplosionPart.Transparency = 0.5 |
09 | ExplosionPart.Shape = 'Ball' |
11 | local start = ExplosionPart.Size |
12 | local finish = ExplosionPart.Size * Vector 3. new( 2 , 2 , 2 ) |
15 | local disipate = script.DisipateEffect:Clone() |
16 | disipate.Parent = ExplosionPart |
17 | disipate.Disabled = false |
19 | for progress = 0 , 1 , 0.03 do |
20 | ExplosionPart.Size = start:lerp(finish, progress) |
Here is the script that clones the script above into the part that touched the players body part
01 | function onDamage(Part) |
02 | if Part.Parent:FindFirstChild( "Humanoid" ) ~ = nil and Part.Parent.Name ~ = "script.Parent.Name" then |
03 | script.Disabled = false |
04 | local effect = script.GiantEffect:Clone() |
06 | effect.Disabled = false |
07 | Part.Parent.Humanoid:TakeDamage( 45 ) |
11 | script.Parent.Touched:connect(onDamage) |