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
 

Help with the On equip fucntions

Previous Thread :: Next Thread 
rewdew2 is not online. rewdew2
Joined: 10 Dec 2009
Total Posts: 168
19 Jul 2013 05:24 PM
so i'm working on an ammo GUI and i need help (surprise surprise.)
what i'm trying to do is make a script that will show your ammo on the ammo gui when you equip the weapon

Here's what i thought would work.

___________________________code_____________
player = script.Parent.Parent.Parent
gui = player.PlayerGui.AmmoGUI
tool = script.Parent
ammo = script.Parent.AmmoScript.Ammo
clip = script.Parent.AmmoScript.Clip


function onEquipped()
gui.Frame.Ammo.Text = "Ammo: "..ammo.Value.."."
gui.Frame.Clip.Text = "Clip: "..clip.Value.."."
wait()
end
script.Parent.Equipped:connect(onEquipped)

_____________________________________________
But it doesn't. and i don't know why. (i'm not an expert with Lua)

Now, i have the GUIs set up properly. i tried one where it said

_______________________code___________________
(parents equal stuff here)

while true do
gui.Frame.Ammo.Text = "Ammo: "..ammo.Value.."."
gui.Frame.Clip.Text = "Clip: "..clip.Value.."."
wait()
end

______________________________________________

That worked fine until the player dies. in which case it goes back to saying "Label" (the default text i have it set to)

I've looked at tutorials, and nothing has helped me.
PLEASE help?!
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
19 Jul 2013 05:34 PM
player = script.Parent.Parent.Parent
gui = player.PlayerGui.AmmoGUI
tool = script.Parent
ammo = script.Parent.AmmoScript.Ammo
clip = script.Parent.AmmoScript.Clip


function onEquipped()
gui.Frame.Ammo.Text = "Ammo: "..ammo.Value.."."
gui.Frame.Clip.Text = "Clip: "..clip.Value.."."
wait()
end
script.Parent.Equipped:connect(onEquipped)

I'm guessing this script is located in the Tool, correct? Also, why do you declare tool, and then never use it again? Do you have any output?
Report Abuse
icanxlr8 is not online. icanxlr8
Joined: 25 Feb 2009
Total Posts: 3686
19 Jul 2013 05:34 PM
Try setting a time for wait. The only other odd thing could be this: script.Parent.Equipped might need to be tool.Equipped, as it may be confusing the script.

{You Want It, Ican Build It}
Report Abuse
rewdew2 is not online. rewdew2
Joined: 10 Dec 2009
Total Posts: 168
19 Jul 2013 05:38 PM
Yeah, if you could throw it together in a better format, that'd be great.

And the reason other things were figured into was because that i MIGHT need to expand on the script, but i wasn't sure.
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