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: Need some help with this script

Previous Thread :: Next Thread 
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
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
orangegreenblue is not online. orangegreenblue
Joined: 04 Sep 2010
Total Posts: 10906
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
orangegreenblue is not online. orangegreenblue
Joined: 04 Sep 2010
Total Posts: 10906
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 is not online. 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
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
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
stuntkid257 is not online. stuntkid257
Joined: 12 Jul 2010
Total Posts: 1394
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 is not online. 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
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
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
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
13 Aug 2011 04:19 PM
BuM.p
Report Abuse
grimm343 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
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
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
13 Aug 2011 07:32 PM
Bump, could anyone help make this script so it works more then once?
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
13 Aug 2011 08:33 PM
Do not add a while loop.
Report Abuse
grimm343 is not online. 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
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Aug 2011 12:23 AM
@grimm - You know, there's a HealthChanged event. :P
Report Abuse
grimm343 is not online. 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 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
14 Aug 2011 12:24 AM
Oh?

Must read up on this. Much appreciated.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Aug 2011 12:24 AM
No problem.
Report Abuse
Stickbullet is not online. Stickbullet
Joined: 30 Apr 2009
Total Posts: 671
16 Aug 2011 02:10 PM
Thanks, it worked :)
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