|
| 13 Aug 2011 02:27 PM |
I'm trying to make a script which causes a door to open when a zombie dies. I dont know much about scripting but heres what I've got:
door = script.Parent zombie = Workspace.Zombie
if zombie.Humanoid.Health = 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end
I know theres no listener or function in there but I didn't know why I would need them and I don't understand what they really do. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 02:28 PM |
door = script.Parent zombie = Workspace.Zombie
if zombie.Humanoid.Health == 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end
still probably doesn't work lol
-orangegreenblue, also THE GAME |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 02:29 PM |
you use 2 = if you are checking a value eg. if troll == true then
-orangegreenblue, also THE GAME |
|
|
| Report Abuse |
|
|
Darkcheez
|
  |
| Joined: 22 Oct 2008 |
| Total Posts: 157 |
|
|
| 13 Aug 2011 02:30 PM |
This script only runs once. It's past the if statement before your player can even load. Try:
door = script.Parent zombie = Workspace.Zombie
while true do --Makes it repeat as long as the script is running if zombie.Humanoid.Health = 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end wait() --So it doesn't crash your computer. end
|
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 02:43 PM |
| Thanks for the advice, I tried both scripts but they didn't work. They door doesn't need to be a model or something right? |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 02:45 PM |
door = script.Parent zombie = game.Workspace.Zombie -- You got the variable wrong.
while true do --Makes it repeat as long as the script is running if zombie.Humanoid.Health = 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end wait() --So it doesn't crash your computer. end |
|
|
| Report Abuse |
|
|
pb23
|
  |
| Joined: 15 Dec 2008 |
| Total Posts: 1469 |
|
|
| 13 Aug 2011 02:46 PM |
Wow not thats a laggy script.
~One of the 1st cframe pugins~
|
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 03:39 PM |
| Thanks for noticing that stuntkid, but it still won't work. The zombie dies but the brick doesn't change at all. This doesn't seem like something impossible it looks very easy compared to other scripts so I don't know why it doesn't work :/ How do you know the script will be laggy pb23? |
|
|
| Report Abuse |
|
|
| |
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 13 Aug 2011 04:21 PM |
@Stunt
You can use game.Workspace, or just ignore the game part completely, as it is not necessary, here. |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 13 Aug 2011 04:28 PM |
door = script.Parent zombie = Workspace.Zombie
function onChange(property) if property == "Health" then if zombie.Humanoid.Health == 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end end end
Zombie.Humanoid.Changed:connect(onChange) |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 13 Aug 2011 04:29 PM |
And if that does not work..
door = script.Parent zombie = Workspace:findFirstChild("Zombie")
function onChange(property) if property == "Health" then if zombie.Humanoid.Health == 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end end end
zombie.Humanoid.Changed:connect(onChange) |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 13 Aug 2011 04:29 PM |
| Oh my.. When I put 'Zombie.Humanoid.Changed', I should have kept the z lower-case.. My bad, on the first script. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 06:04 PM |
Thanks the first one worked. But it only works once and I want the door to open whenever the zombie dies. So I tried to change the script to this:
door = script.Parent zombie = Workspace.Zombie
function onChange(property) if property == "Health" then if zombie.Humanoid.Health == 0 then while true do --Added this door.Transparency = 0.5 door.CanCollide = false wait(3) door.Transparency = 0 door.CanCollide = true end end end
zombie.Humanoid.Changed:connect(onChange)
I thought it would make it do what I wanted instead it just caused the script to stop working. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2011 07:32 PM |
| Bump, could anyone help make this script so it works more then once? |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
| |
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 14 Aug 2011 12:21 AM |
Try this one.. This goes inside of the zombie. Make sure it respawns with it, too. Oh, and put the door path where it says 'doorpathHERE'. :s
door = doorpathHERE zombie = script.Parent
function onChange(property) if property == "Health" then if zombie.Humanoid.Health == 0 then while true do --Added this door.Transparency = 0.5 door.CanCollide = false wait(3) door.Transparency = 0 door.CanCollide = true end end end
zombie.Humanoid.Changed:connect(onChange) |
|
|
| Report Abuse |
|
|
|
| 14 Aug 2011 12:23 AM |
| @grimm - You know, there's a HealthChanged event. :P |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 14 Aug 2011 12:23 AM |
Whoops, accidentally copied yours.
door = doorpathHERE zombie = script.Parent
function onChange(property) if property == "Health" then if zombie.Humanoid.Health == 0 then if door.Transparency == 0 then door.Transparency = 0.5 door.CanCollide = false wait(20) door.Transparency = 0 door.CanCollide = true end end end end
script.Parent.Humanoid.Changed:connect(onChange) |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 14 Aug 2011 12:24 AM |
Oh?
Must read up on this. Much appreciated. |
|
|
| Report Abuse |
|
|
| |
|
| |
|