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 » Scripters
Home Search
 

Re: What exactly is causing this?

Previous Thread :: Next Thread 
Ahrinmor is not online. Ahrinmor
Joined: 25 Dec 2012
Total Posts: 534
31 Jan 2015 06:57 PM
This is the code for a health bar I wrote. It runs fine in solo testing, but in test and live servers it just gives me an error in the output (below) and I'm not sure why. Everything is in the correct places and I've tried it a few different ways, but I'm still not sure what's causing it to fail.
____
Code

char = game.Players.LocalPlayer.Character
hum = char.Humanoid
hum.Changed:connect(function()
script.Parent.Frame.Healthbar.Health.Size = UDim2.new(hum.Health/hum.MaxHealth-0.02,0,0.8,0)
end)

____
Output

18:54:50.235 - Players.Player1.PlayerGui.ServerGui.LocalScript:2: attempt to index global 'char' (a nil value)
Report Abuse
joelsdarkside22 is not online. joelsdarkside22
Joined: 18 Mar 2009
Total Posts: 1131
31 Jan 2015 07:01 PM
char = game.Players.LocalPlayer.Character
hum = char.Humanoid
hum.Changed:connect(function()
script.Parent.Frame.Healthbar.Health.Size = UDim2.new(hum.Health/hum.MaxHealth-0.02,0,0.8,0)
end)
local p=game.Players.LocalPlayer
local c=p.Character or p.CharacterAdded
c:WaitForChild'Humanoid'.Changed:connect(function()
script.Parent.Frame.Healthbar.Health.Size=UDim2.new(c.Humanoid.Health/c.Humanoid.MaxHealth-.02,0,.8,0)
end)
Report Abuse
Ahrinmor is not online. Ahrinmor
Joined: 25 Dec 2012
Total Posts: 534
31 Jan 2015 07:25 PM
With that none of it works at all.
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
31 Jan 2015 07:27 PM
Put;

repeat wait() until game.Players.LocalPlayer

In the beginning of your script

Like before everything
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Jan 2015 07:27 PM
No, that's just a useless wait()
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
31 Jan 2015 07:28 PM
Its a localscript, It can run before the player joins
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Jan 2015 07:31 PM
Nah
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
31 Jan 2015 07:32 PM
Yea
Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
31 Jan 2015 07:37 PM
Is it inside a localscript?
if so, do this.
player = game.Players.LocalPlayer
character = player.Character
hum = cahracter.Humanoid
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Jan 2015 07:37 PM
Nope
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
31 Jan 2015 07:38 PM
Yep It does
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Jan 2015 07:38 PM
Nah
Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
31 Jan 2015 07:38 PM
*Character
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
31 Jan 2015 07:40 PM
Quote from the wiki:

"do not run server-side, but instead, perform their actions on the client"
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 Jan 2015 07:41 PM
Are you dumb? We are not even "arguing" about that, we are "arguing" about whether they run before the PLAYER exists.
Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
31 Jan 2015 07:42 PM
they dont run before the player exists. how would they?
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
31 Jan 2015 07:43 PM
A local script that runs on the client cannot run before the client even exists. #logic
Report Abuse
QuintinityZero is not online. QuintinityZero
Joined: 01 Oct 2008
Total Posts: 10618
31 Jan 2015 07:47 PM
rofl, "localscripts can run before their parent client exists" ayy
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
31 Jan 2015 07:48 PM
Ok nevermind then
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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