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: Scaling health

Previous Thread :: Next Thread 
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
18 Jul 2014 06:23 PM
So this is my RPGscript, but the health scaling is not working.
It just is 100 health and it stays 100 health during all levels.
Whats wrong with it?
The rest all works fine.
b stands at top of the script, if you may ask.



b = 5
function onXPChanged(player, XP, level)
if XP.Value>=level.Value * 25 then
XP.Value = XP.Value - level.Value * 25
level.Value = level.Value + 1
end
end

function onLevelUp(player, XP, level)
if player.Character~=nil then
for i = 1,5 do
local fireworks = Instance.new("Part")
fireworks.Shape = 0
fireworks.formFactor = "Symmetric"
fireworks.Size = Vector3.new(1,1,1)
fireworks.BrickColor = BrickColor.Random()
fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0)
fireworks.Parent = game.Workspace
game:GetService("Debris"):AddItem(fireworks, 2)
fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
end
end
for i = 1, level do
health = health + health/100*b
end
player.Character.Humanoid.Health = health
player.Character.Humanoid.MaxHealth = health
local m = Instance.new("Hint")
m.Parent = game.Workspace
m.Text = player.Name .. " has gained a level!"
wait(5)
m.Parent = nil
end

function onPlayerRespawned(player)
wait(5)
for i = 1, level do
health = health + health/100*b
end
player.Character.Humanoid.Health = health
player.Character.Humanoid.MaxHealth = health
--[[
local stuff = player.Backpack:GetChildren()
wait(5)
for i = 1,#stuff do
local name = stuff[i].Name
if game.Starterpack:findFirstChild(name)==nil then
stuff[i]:Clone().Parent = player.Backpack
end
end
--]]
end

function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"

local xp = Instance.new("IntValue")
xp.Name = "XP"
xp.Value = 0

local level = Instance.new("IntValue")
level.Name = "Level"
level.Value = 0

local gold = Instance.new("IntValue")
gold.Name = "Gold"
gold.Value = 0

xp.Parent = stats
level.Parent = stats
gold.Parent = stats

stats.Parent = newPlayer

xp.Changed:connect(function() onXPChanged(newPlayer, xp, level) end)
level.Changed:connect(function() onLevelUp(newPlayer, xp, level) end)

newPlayer.Changed:connect(function (property)
if (property == "Character") then
onPlayerRespawned(newPlayer)
end
end)
end

game.Players.ChildAdded:connect(onPlayerEntered)
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 05:07 AM
bump
Report Abuse
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
19 Jul 2014 05:22 AM
You should define health before adding to the variable

Example:
health = player.Character.Humanoid.Health

health = health + health/100*b
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 05:34 AM
still doesn't work :S
Put it in like this:

health = player.Character.Humanoid.Health
for i = 1, level do
health = health + health/100*b
end
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 06:08 AM
bump
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 07:39 AM
Darude Sandstorm
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 08:17 AM
bump
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 08:45 AM
bump
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 09:16 AM
bump
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 09:37 AM
bump
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 10:02 AM
Come on SH..
Report Abuse
KingJacko is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
19 Jul 2014 10:05 AM
try to find out where the error is first. Use output. Use the developer console. Put prints everywhere and see which ones dont come up.
Report Abuse
RealistK is not online. RealistK
Joined: 20 Feb 2011
Total Posts: 3489
19 Jul 2014 10:41 AM
bump
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