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
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
RealistK
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|
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
|
  |
| Joined: 20 Feb 2011 |
| Total Posts: 3489 |
|
| |
|