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: If your a good scripter please help me

Previous Thread :: Next Thread 
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
22 Jun 2013 08:41 AM
Ok so I made a script that inserts a number value into a player that enters my game and I was wondering, how do you make that player's MaxHealth to be the value of the number value inside them?
Report Abuse
Unsubstantial is not online. Unsubstantial
Joined: 11 Sep 2012
Total Posts: 872
22 Jun 2013 08:42 AM
game.Players. PLAYER HERE .Character.Humanoid.MaxHealth=value.Value
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
22 Jun 2013 08:43 AM
script.Parent.Humanoid.MaxHealth = script.Parent.NumValue.Value
Report Abuse
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
22 Jun 2013 08:48 AM
Guys it isnt in the player's character, It's in their player. So that wont work
Report Abuse
Unsubstantial is not online. Unsubstantial
Joined: 11 Sep 2012
Total Posts: 872
22 Jun 2013 09:02 AM
OK, learn some basics before you actually come here then. You should know how to edit the scripts we provided - if not, then leave.
Report Abuse
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
22 Jun 2013 09:28 AM
I tried every possible way to do it. If I edit that script up there it wouldnt work... Dont post if your not here to help people...
Report Abuse
RoAnt is not online. RoAnt
Joined: 14 Jul 2008
Total Posts: 16794
22 Jun 2013 09:36 AM
"Dont post if your not here to help people..."

He did helped. If you have learn the basic... such as "parent-child relationship between objects "

http://wiki.roblox.com/index.php/Absolute_beginner%27s_guide_to_scripting
Report Abuse
TrueSoulWolf is not online. TrueSoulWolf
Joined: 02 Apr 2011
Total Posts: 460
22 Jun 2013 09:38 AM
What is the exact parent of the value?
Report Abuse
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
22 Jun 2013 09:53 AM
script.Parent.Humanoid.MaxHealth = script.Parent.NumValue.Value

If I changed that to:


script.Parent.Humanoid.MaxHealth = script.Parent.Parent.NumValue.Value

It still wouldnt work. Plus I do know the basics I came here cause I thought the was a unique way to do it cause no matter what way I do it it wouldnt work so stop posting links and telling me to learn the basics and help me out if you know how to do it.
Report Abuse
TrueSoulWolf is not online. TrueSoulWolf
Joined: 02 Apr 2011
Total Posts: 460
22 Jun 2013 09:55 AM
I mean exactly where is the NumValue? Directly parented by Player or Character or what?
Report Abuse
Unsubstantial is not online. Unsubstantial
Joined: 11 Sep 2012
Total Posts: 872
22 Jun 2013 09:58 AM
Then you are doing something wrong yourself. Don't just assume I'm "not here to help people" - I gave you a perfectly clear answer.
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
22 Jun 2013 10:02 AM
If the NumValue is directly parented into the player:

script.Parent.Character.Humanoid.MaxHealth = script.Parent.NumValue.Value

If the NumValue is directly parented into the character:

script.Parent.Character.Humanoid.MaxHealth = script.Parent.Character.NumValue.Value
Report Abuse
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
22 Jun 2013 10:06 AM
So I put the script into the player as well?
Report Abuse
Preston99 is not online. Preston99
Joined: 21 Sep 2008
Total Posts: 247
22 Jun 2013 10:35 AM
Dear god. The might of a thousand suns could not comprehend the amount of stupid this poor fellow contains.

Read what they said, for christ's sake man.
Report Abuse
blockold is not online. blockold
Joined: 25 Aug 2008
Total Posts: 1411
22 Jun 2013 11:08 AM
If you want everyone's health to be the number do this:

game.Players.PlayerAdded:connect(function(plr)
plr.Character.Humanoid.MaxHealth = game.Workspace.NumberValue.Value
plr.Character.Humanoid.Health = plr.Character.Humanoid.MaxHealth
end)
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
22 Jun 2013 10:52 PM
@block - That won't work, you've got to use CharacterAdded or at least wait until their character exists.
Report Abuse
blockold is not online. blockold
Joined: 25 Aug 2008
Total Posts: 1411
23 Jun 2013 05:19 AM
Oi D:
Report Abuse
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
23 Jun 2013 05:38 AM
You guys dont understand what im saying. NONE OF YOUR ANSWERS WORK WHY CANT YOU UNDERSTAND THAT??? NO MATTER WHAT I DO IT WONT WORK!!!
Report Abuse
Ferseus is not online. Ferseus
Joined: 23 May 2013
Total Posts: 247
23 Jun 2013 05:39 AM
I was just wondering if anyone knew a better way than the ones you guys are spamming!
Report Abuse
RoAnt is not online. RoAnt
Joined: 14 Jul 2008
Total Posts: 16794
23 Jun 2013 05:49 AM

function PlayerAdded(player)
local object_numbervalue = Instance.new("NumberValue",player)
object_numbervalue.Value = 200
player.CharacterAdded:connect(function(char)
char:WaitForChild("Humanoid")
char.Humanoid.MaxHealth = object_numbervalue.Value
end)
end


game.Players.PlayerAdded:connect(PlayerAdded)
for _,v in pairs(game.Players:GetPlayers()) do PlayerAdded(v) end
Report Abuse
RoAnt is not online. RoAnt
Joined: 14 Jul 2008
Total Posts: 16794
23 Jun 2013 05:55 AM
The code I posted WILL indeed work.
I've tested it.

This code will create a number value. The parent of the number value will be in the Player.
The MaxHealth of the player WILL BE 200 because of "char.Humanoid.MaxHealth = object_numbervalue.Value"

Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
23 Jun 2013 07:20 AM
RoAnt, I might be wrong but your script only works if a player is added.
So when you join, indeed your maxhealth will be increased but when you die you will have 100 health again.

Also it might not work when testing it because the script loads before the player in test mode, so your script probably works (only once) but also has to be tested in a running server. (Press F7, then press Alt+F7 on new screen to test it correct)

I made this a little different so it also changes your maxhealth when you died.
I used two scripts, one that adds a value to the player if he has none yet and adds a player into the player.
The other script changes the MaxHealth. (Added a loop to it, so maxhealth gets adjusted every 2 seconds, you can easily remove that)


I decided to upload it as a model because it will be easier to install. (Put the whole lot in StarterGui.
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
23 Jun 2013 07:20 AM
Forgot to add the link lol:

http://www.roblox.com/Set-Max-Health-to-value-in-player-item?id=120121361
Report Abuse
RoAnt is not online. RoAnt
Joined: 14 Jul 2008
Total Posts: 16794
23 Jun 2013 07:25 AM
"RoAnt, I might be wrong but your script only works if a player is added.
So when you join, indeed your maxhealth will be increased but when you die you will have 100 health again."

You're wrong; I added the generic for at the end, which will allow you to test the function in solo. No, when you die and then respawn, the CharacterAdded event will be fired.

"Also it might not work when testing it because the script loads before the player in test mode, so your script probably works (only once) but also has to be tested in a running server"

As I said above. I've used generic for to fire the function. Nope. Tested.
Works.
Report Abuse
awsomeness252 is not online. awsomeness252
Joined: 30 May 2009
Total Posts: 18
23 Jun 2013 07:27 AM
So you'd have your on player entered stuff here
______________________________________
--Then you'd want something like this
player.Character.Humanoid.Health=number
--You could use MaxHealth too
--You probably defined player on the player entered script but it might be somthing like
newPlayer
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