How do I put a script inside a player's body parts when it dies?
Before anything else, I just like to mention that I'm an absolute noob in scripting. I know there is a lot to improve on the script I will show you. The redundancies might make you cringe.
I'm trying to make a death effect similar to getting shot by the Hyperlaser Gun gear. So, whenever a player dies, the body parts become anchored and transparent; selection boxes and lights will appear and fade out; and eventually the parts are destroyed. I made a function that does exactly that.
THE PROBLEM: * I have no clue how to integrate the function into a player's body parts whenever someone dies.*
I heard it has to do something with the "Died()" event. How do I do it?
Here's the "HyperDeath" function
01 | local function HyperDeath(instance) |
02 | local function SelectionBoxify(instance) |
03 | local selectionBox = Instance.new( 'SelectionBox' ) |
04 | selectionBox.Adornee = instance |
05 | selectionBox.Color = BrickColor.new( 'New Yeller' ) |
06 | selectionBox.Parent = instance |
07 | selectionBox.Transparency = 0.3 |
11 | local function Light(instance) |
12 | local light = Instance.new( 'PointLight' ) |
13 | light.Parent = instance |
14 | light.Color = Color 3. new( 255 , 255 , 0 ) |
19 | local function Freeze(instance) |
24 | local function Hide(instance) |
29 | local function FadeSelection(instance) |
30 | local part = instance.SelectionBox |
31 | local increment = 0.05 |
32 | while part.Transparency < 1 do |
33 | part.Transparency = part.Transparency + increment |
38 | local function Vanish(instance) |
41 | part.Parent = instance |
45 | SelectionBoxify(instance) |
50 | FadeSelection(instance) |
Am I on the right track? Or am I totally way off? Thank you in advance for your feedback. :D