generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Fade on death script won't work?

Previous Thread :: Next Thread 
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
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
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
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
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
21 Oct 2012 07:01 PM
oh
Report Abuse
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
21 Oct 2012 07:04 PM
But why are you finding the children of a humanoid of the monster?
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
21 Oct 2012 07:05 PM
Oh, sorry, that should just be script.Parent. My bad.
Report Abuse
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
21 Oct 2012 07:08 PM
Can you tell me the fixed script? I can't quite understand it yet.
Report Abuse
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
21 Oct 2012 07:09 PM
I need it to get children that are parts to fade.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
21 Oct 2012 07:14 PM
Remove:

":FindFirstChild("Monster")"

And check if the child is a part.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
21 Oct 2012 07:19 PM
Yes, but remove the function, and connection line.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
21 Oct 2012 07:25 PM
What if I have a fake head on the NPC?
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
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 is not online. 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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
21 Oct 2012 07:30 PM
@Ten

Not really.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
gametastic100 is not online. gametastic100
Joined: 15 Jun 2011
Total Posts: 1286
21 Oct 2012 07:30 PM
So would removing it before I make the parts fade would work?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
21 Oct 2012 07:31 PM
Yes.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image