|
| 21 Oct 2012 06:55 PM |
I tried to make the enemy fade on death but it just turns invisible all of a sudden. Here's the script:
function onPlayerDied(dead) local h = script.Parent.Monster if (h.Health == 0) then for i = 1,10 do script.Parent.Head.Transparency = i/10 end wait(0.1) for i = 1,10 do script.Parent.Torso.Transparency = i/10 end wait(0.1) for i = 1,10 do script.Parent["Left Leg"].Transparency = i/10 end wait(0.1) for i = 1,10 do script.Parent["Right Leg"].Transparency = i/10 end wait(0.1) for i = 1,10 do script.Parent["Left Arm"].Transparency = i/10 end wait(0.1) for i = 1,10 do script.Parent["Right Arm"].Transparency = i/10 end wait(0.1)
end end
script.Parent.Monster.Died:connect(onPlayerDied)
|
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 06:58 PM |
script.Parent:FindFirstChild("Monster").Died:wait() for _,v in pairs(script.Parent:FindFirstChild("Monster"):GetChildren())do for i=1,0,-.1 do v.Transparency=i wait(.01) -- this is your problem. wait must be inside the loop! end end
The above is just an efficient version of your script.
The problem with your script is that you don't put any waits *inside* the for loops. |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Oct 2012 07:04 PM |
| But why are you finding the children of a humanoid of the monster? |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:05 PM |
| Oh, sorry, that should just be script.Parent. My bad. |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:08 PM |
| Can you tell me the fixed script? I can't quite understand it yet. |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:09 PM |
| I need it to get children that are parts to fade. |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:14 PM |
Remove:
":FindFirstChild("Monster")"
And check if the child is a part.
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:18 PM |
Like this?:
function onPlayerDied(dead)
script.Parent:FindFirstChild("Monster").Died:wait() for _,v in pairs(script.Parent:GetChildren())do if v:IsA("Part") then for i = 1,0,-.1 do v.Transparency = i wait(.01) end end end
script.Parent.Monster.Died:connect(onPlayerDied)
|
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:19 PM |
Yes, but remove the function, and connection line.
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:25 PM |
| What if I have a fake head on the NPC? |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:28 PM |
script.Parent:FindFirstChild("Monster").Died:wait() for _,v in pairs(script.Parent:GetChildren())do if v:IsA("Part")then for i=1,0,-.1 do v.Transparency=i wait(.01) end end end
This should still work if there is a fake head, unless that fake head is in a model. Then it'd be something like...
script.Parent:FindFirstChild("Monster").Died:wait() for _,v in pairs(script.Parent:GetChildren())do if v:IsA("Part")then table.insert(v,v:FindFirstChild("FakeHead"):FindFirstChild("Head")) for i=1,0,-.1 do v.Transparency=i wait(.01) end end end
Just change FakeHead to the model the fake head is in, and Head to the name of the fake head. |
|
|
| Report Abuse |
|
|
TenGauge
|
  |
| Joined: 22 Sep 2012 |
| Total Posts: 202 |
|
|
| 21 Oct 2012 07:29 PM |
wait() and wait(.01)
are the same as wait(.33) |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:30 PM |
@Ten
Not really.
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
|
| 21 Oct 2012 07:30 PM |
| So would removing it before I make the parts fade would work? |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Oct 2012 07:44 PM |
You're wrong.
wait() Is about the same was wait(.03) in a server script *****
in a local script, wait() can be *anything*. The player gets to choose that in the settings of Roblox on their computer, which is why people should get in the habbit of always putting a number in those parenthesis...
waiting less than .03 usually just waits one frame rate (not FPS frame rate, but that at which the engine is running) to delay
Contrary to popular belief, wait(0) is the same as wait(), rather than simply waiting one frame rate. This is the same in Local and Server Scripts. :) |
|
|
| Report Abuse |
|
|
TenGauge
|
  |
| Joined: 22 Sep 2012 |
| Total Posts: 202 |
|
|
| 21 Oct 2012 08:27 PM |
| That was a fail on my part. Need to stop being dyslexic with numbers. |
|
|
| Report Abuse |
|
|