|
| 13 May 2015 07:52 PM |
So basically this code is supposed to constantly make the int value of the player's smithing xp the value of the intvalue inside the textbutton (inside the first loop) and the second loop which is the one that doesn't work it supposed to check the player's smithing xp stat and if it's value is greater than 99, make the xp equal to 0 and add one value to the smithing int value of the player. I tried making this all one loop, I've tried everything, either it's buggy like adds 2 levels instead of one or doesn't work. Any help?
local db = false while wait() do if not db then db = true wait() local player = script.Parent.Parent.Parent.Parent local xrp = script.Parent.xp.Value script.Parent.xp.Value = player.Stats.Smithing.xp.Value script.Parent.Text = "Xp: ".. xrp
db = false end end
while wait() do wait() local player = script.Parent.Parent.Parent.Parent if player.Stats.Smithing.xp.Value >= 100 then player.Stats.Smithing.Value = player.Stats.Smithing.Value + 1 wait() player.Stats.Smithing.xp.Value = 0 wait(.05) end end |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 07:57 PM |
| Where is this located, and what type of script is it? |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 08:00 PM |
So basically location is Player > PlayerGui > ScreenGui > exp (Textbutton) > script regular script not local |
|
|
| Report Abuse |
|
|
|
| 13 May 2015 08:04 PM |
I would do something like this as I'd assume you would later increase the area of xp range. That way it would be harder to achieve new levels.
local determiningfactor = 5 -- Rate of growth if xp.Value >= (Smithing.Value * determiningfactor) then xp.Value = xp.Value - (Smithing.Value * determiningfactor) Smithing.Value = Smithing.Value + 1 end |
|
|
| Report Abuse |
|
|
|
| 14 May 2015 02:13 PM |
| The second loop won't work though |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 14 May 2015 02:15 PM |
local db = false local player = script.Parent.Parent.Parent.Parent local xrp = script.Parent.xp.Value while wait() do if not db then db = true wait() script.Parent.xp.Value = player.Stats.Smithing.xp.Value script.Parent.Text = "Xp: ".. xrp db = false end end
spawn(function() while wait() do wait() if player.Stats.Smithing.xp.Value >= 100 then player.Stats.Smithing.Value = player.Stats.Smithing.Value + 1 wait() player.Stats.Smithing.xp.Value = 0 wait(.05) end end end) |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 14 May 2015 02:15 PM |
oops
local db = false local player = script.Parent.Parent.Parent.Parent local xrp = script.Parent.xp.Value
spawn(function() while wait() do if not db then db = true wait() script.Parent.xp.Value = player.Stats.Smithing.xp.Value script.Parent.Text = "Xp: ".. xrp db = false end end end)
while wait() do wait() if player.Stats.Smithing.xp.Value >= 100 then player.Stats.Smithing.Value = player.Stats.Smithing.Value + 1 wait() player.Stats.Smithing.xp.Value = 0 wait(.05) end end
|
|
|
| Report Abuse |
|
|