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: Why wont this work?

Previous Thread :: Next Thread 
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
16 Nov 2013 11:02 AM
The parent is PlayerGui

Player = script.Parent.Parent.Parent.Parent.Parent


while wait() do
Human = Player.Character.Humanoid
Gun = Player.Character.Devastator
Bar.Size = UDim2.new(( Gun.Handle.Ammo.Value / 6) * 1,0,1,0)
end





[::Group in progress::] http://web.roblox.com/My/Groups.aspx?gid=973579
Report Abuse
Quorum is not online. Quorum
Joined: 25 Oct 2013
Total Posts: 4680
16 Nov 2013 11:06 AM
1) I'd use a LocalScript (easier to get the player).
2) I'd use the 'Changed' event, instead of a loop.
3) You should check to see if the gun is there, before running the code. Or, only running when the weapon is there.
Report Abuse
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
16 Nov 2013 11:13 AM
How should I conduct the Changed event?

[::Group in progress::] http://web.roblox.com/My/Groups.aspx?gid=973579
Report Abuse
Quorum is not online. Quorum
Joined: 25 Oct 2013
Total Posts: 4680
16 Nov 2013 11:22 AM
Example, based on your code (assuming everything is defined).

Gun.Handle.Ammo.Changed:connect(function(NewVal)
Bar.Size = UDim2.new(( NewVal / 6) * 1,0,1,0)
end)
Report Abuse
darkwisp is not online. darkwisp
Joined: 07 Apr 2010
Total Posts: 22653
16 Nov 2013 11:32 AM
Player = script.Parent.Parent.Parent.Parent.Parent
Bar = script.Parent
tool = script.Parent.Parent.Parent.Parent
tool.Equipped:connect(function(mouse)
Player.Character.Devastator.Handle.Ammo.Value.Changed:connect(function(change)
Human = Player.Character.Humanoid
Gun = Player.Character.Devastator
Bar.Size = UDim2.new(( Gun.Handle.Ammo.Value / 6) * 1,0,1,0)
end)
end)


[::Group in progress::] http://web.roblox.com/My/Groups.aspx?gid=973579
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