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: Onclick GUI (Get hp help?)

Previous Thread :: Next Thread 
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
14 Sep 2015 08:38 PM
Soooo i'm trying to find a way to make my Armor GUI give hp (On-click)

Anyone know how one would do this?
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
14 Sep 2015 08:48 PM
ive seen it dont in the wiki before


your not who you are when you are who you are trying to be
Report Abuse
2090mazmaz is not online. 2090mazmaz
Joined: 09 Oct 2012
Total Posts: 567
14 Sep 2015 08:48 PM
done*


your not who you are when you are who you are trying to be
Report Abuse
SaveDaTurtlesMan is not online. SaveDaTurtlesMan
Joined: 09 Dec 2013
Total Posts: 260
14 Sep 2015 09:07 PM
button.MouseButton1Down:connect(function()
end)
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
15 Sep 2015 09:11 PM
Let's say i have a ''Textbox'' (I Do) How do i make it that when you click that textbox it updates your current hp

For example

--Starts with 100 hp---
(Clicks Textbox)
--Get's 250 Max hp--









U W0T M80?
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
15 Sep 2015 09:44 PM
Also MouseButton1Down wouldn't work,
MouseButton1Click would...yeees?
Report Abuse
Vendicular is not online. Vendicular
Joined: 12 Apr 2013
Total Posts: 218
15 Sep 2015 09:55 PM
MAKE SURE THE SCRIPT IS A LOCAL SCRIPT



texting = [directory to textbox]

texting.MouseButton1Down:connect(function()
game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.Health + 2
end)
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
15 Sep 2015 09:57 PM
Awwwww daum, forgot to make it local
*Facepalm*
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
15 Sep 2015 10:19 PM
Didn't work...any ideas?
Report Abuse
iFallenAtlantis is not online. iFallenAtlantis
Joined: 29 Feb 2012
Total Posts: 240
16 Sep 2015 12:20 AM
It didn't work because he set the Health, and not the MaxHealth:

texting = [directory to textbox]
local MH = game.Players.LocalPlayer.Character.Humanoid.MaxHealth
local H = game.Players.LocalPlayer.Character.Humanoid.Health

texting.MouseButton1Down:connect(function()
MH = MH + 150
H = H + 150 - The health must be called after MaxHealth, or it won't work.
end)

This will set MaxHealth to 250, and instantly set the Health to 250, so the character won't have to heal to get to 250 health.


You can also add a debounce so the function runs once:

texting = [directory to textbox]
local MH = game.Players.LocalPlayer.Character.Humanoid.MaxHealth
local H = game.Players.LocalPlayer.Character.Humanoid.Health
local debounce = false

texting.MouseButton1Down:connect(function()
if debounce = false then
MH = MH + 150
H = H + 150
debounce = true
end)

Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
16 Sep 2015 04:46 PM
Thank's but...
why are we adding this?

texting = [directory to textbox]

It causes the script to error up.
Report Abuse
iFallenAtlantis is not online. iFallenAtlantis
Joined: 29 Feb 2012
Total Posts: 240
16 Sep 2015 08:41 PM
For the

texting = [directory to textbox]

part, you are supposed to put the location of the textbox.

For example:

If you have a part inside of a model in Workspace, you would write the directory like this:

part = game.Workspace.Model.Part

For something in the Player's gui, like the button you want to make, it would be more like this:

texting = game.Players.LocalPlayer.PlayerGui.[Fill in the rest]
(LocalPlayer only works in a LocalScript, and LocalScripts will only work in the PlayerGui, or in the player's backpack.)

Example:

texting = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox

Because I don't know the exact location for your textbox, you will have to figure out exactly what goes after the PlayerGui.



--I can put my waits wherever I want.
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
18 Sep 2015 09:12 PM
Ok so...what goes on is

PlayerGui.ArmorGui.Container.ScrollingFrame.Template

(The script is after that, not sure if i should add it)

So why isn't it working?
Report Abuse
iFallenAtlantis is not online. iFallenAtlantis
Joined: 29 Feb 2012
Total Posts: 240
24 Sep 2015 08:59 PM
The exact location would be:

textbox = game.Players.LocalPlayer.PlayerGui.ArmorGui.Container.ScrollingFrame.Template

Be sure the code is in a LocalScript.



--I can put my waits wherever I want.
Report Abuse
galio13 is not online. galio13
Joined: 20 Jul 2011
Total Posts: 842
25 Sep 2015 12:07 AM
ok I have tested this and this script will do it:

I made a screenGui and a textbutton in that and so a script in the textbutton,

#code

local button = script.Parent
button.MouseButton1Down:connect(function()
local h = script.Parent.Parent.Parent.Parent.Character.Humanoid
h.MaxHealth = 250
end)
Report Abuse
iFallenAtlantis is not online. iFallenAtlantis
Joined: 29 Feb 2012
Total Posts: 240
25 Sep 2015 11:39 PM
I never thought of putting the script in the TextBox... Good thinking Galio, and nice seeing you again. ;)



--I can put my waits wherever I want.
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
28 Sep 2015 10:23 PM
I Tried both your idea's but they don't work...
At this point in the process i'm going to ask that you take a direct look at my model and tell me if it's ok...i may have screwed something up

MODEL LINK, http://www.roblox.com/GUI-Armor-shop-item?id=301602159

Thank you :)
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