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: Script doesn't wait

Previous Thread :: Next Thread 
Kondou is not online. Kondou
Joined: 05 Aug 2012
Total Posts: 1148
08 Apr 2013 06:14 PM
local h = game.Players.LocalPlayer.Character.Humanoid
h.Changed:connect(function()
script.Parent.Size = UDim2.new(0,(h.Health*1.5),0.02,0)
end)


It gives this error
19:11:59.341 - Players.Player1.PlayerGui.MainGui.Health.Health.LocalScript:1: attempt to index field 'Character' (a nil value)

But if I disable/re-enable it there is no error.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
08 Apr 2013 06:15 PM
add a wait(0.1) to the top.
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
08 Apr 2013 06:15 PM
put this at the top

repeat wait() until game.Players.LocalPlayer.Character
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
08 Apr 2013 06:16 PM
wait(0.1) still wont work on people with really slow computers.
Report Abuse
Kondou is not online. Kondou
Joined: 05 Aug 2012
Total Posts: 1148
08 Apr 2013 06:18 PM
repeat wait() until game.Players.LocalPlayer.Character

Worked, thanks.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
08 Apr 2013 06:18 PM
Actually, do this:

p=game.Players.LocalPlayer
p.CharacterAdded:connect(function(char)
char:FindFirstChild("Humanoid").Changed:connect(function()
script.Parent.Size = UDim2.new(0,(h.Health*1.5),0.02,0)
end) end)
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