How would I make the "LightExplosion" part fling after its first instance?
Asked by
7 years ago Edited 7 years ago
How come this script only flings for the first instance of "LightExplosion" In another script a ball named lightexplosion is created in the workspace and then after a few seconds it disappears, so there will never be more than one "LightExplosion" in the server at a time. It only flings the first time it is touched, but when it disappears and another lightexplosion is made it doesn't work on the second one. Here's the script for the fling:
02 | local Part = game.Workspace:WaitForChild( "LightExplosion" ) |
04 | local Debris = game:GetService( 'Debris' ) |
06 | local CharacterToIgnore = script:WaitForChild( 'CharacterToIgnore' ).Value |
09 | local TIME_OF_FORCE = 0.2 |
11 | Part.Touched:connect( function (other) |
12 | if other.Parent = = CharacterToIgnore or (other.Parent and other.Parent.Parent = = CharacterToIgnore) then return end |
13 | if not other.Anchored then |
14 | local punchSound = script:FindFirstChild( 'PunchSound' ) |
15 | if punchSound then punchSound:Play() end |
16 | local direction = (other.Position - Part.Position).unit |
17 | local bodyForce = Instance.new( 'BodyForce' ) |
18 | bodyForce.force = MAGNITUDE * direction |
19 | bodyForce.Parent = other |
20 | Debris:AddItem(bodyForce, TIME_OF_FORCE) |