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: Level Gui

Previous Thread :: Next Thread 
JonathanW123 is online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
10 Jul 2015 09:25 PM
What if I want to make it so you need 20 more than you had before to get to the next level. for example, for level 2, you need 100, for 3, 120, for 4, 140, for 5, 160, for 6, 180

local Stats = game.Players.LocalPlayer:WaitForChild("leaderstat")
local StatsServer = game.ReplicatedStorage:WaitForChild("Stats")
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://145486927"
sound.Parent = script.Parent

script.Parent.Frame:TweenSize(UDim2.new(Stats.CurrentXP.Value/(100), 0, 1, 0), "Out", "Linear", .2, true)
script.Parent.TextLabel.Text = "Current Level: "..Stats.Level.Value.." || Level Progress: "..math.ceil(Stats.CurrentXP.Value).."%"

if Stats.CurrentXP.Value >= 100 then
local Extra = Stats.CurrentXP.Value - 100
script.Parent.Frame:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Linear", 0.2, true)
wait(0.2)
StatsServer:FireServer("UpdateLevel")
StatsServer:FireServer("UpdateXP", Extra)
-- Update instantly, Even thought the Changed will fire again. It's better for instant results.
-- (Latency may stop instant update)
script.Parent.Frame:TweenSize(UDim2.new(Extra/(100), 0, 1, 0), "Out", "Linear", 0.2, true)
script.Parent.TextLabel.Text = "Current Level: "..Stats.Level.Value.." || Level Progress: "..math.ceil(Stats.CurrentXP.Value).."%"
end

Stats.CurrentXP.Changed:connect(function()
sound:Play()
if Stats.CurrentXP.Value >= 100 then
local Extra = Stats.CurrentXP.Value - 100
script.Parent.Frame:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Linear", 0.2, true)
wait(0.2)
StatsServer:FireServer("UpdateLevel")
StatsServer:FireServer("UpdateXP", Extra)
-- Update instantly, Even thought the Changed will fire again. It's better for instant results.
-- (Latency may stop instant update)
script.Parent.Frame:TweenSize(UDim2.new(Extra%100/(100), 0, 1, 0), "Out", "Linear", 0.2, true)
script.Parent.TextLabel.Text = "Current Level: "..Stats.Level.Value.." || Level Progress: "..math.ceil(Stats.CurrentXP.Value).."%"
else
script.Parent.Frame:TweenSize(UDim2.new(Stats.CurrentXP.Value/(100), 0, 1, 0), "Out", "Linear", .2, true)
script.Parent.TextLabel.Text = "Current Level: "..Stats.Level.Value.." || Level Progress: "..math.ceil(Stats.CurrentXP.Value).."%"
end
end)


I'm just here so I don't get fined
Report Abuse
JonathanW123 is online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
10 Jul 2015 09:42 PM
b


I'm just here so I don't get fined
Report Abuse
BStandsForBuilding is online. BStandsForBuilding
Joined: 06 Apr 2015
Total Posts: 651
10 Jul 2015 10:10 PM

Well, first you're going to need a few different values which are:

XP -Value will be 0
MaxXP -Value will be 100
Level -Value will be 1

Then you're going to put those inside of the player, or use fit to your needs.

After that, make it so that when the XP is greater than or equal to the "MaxXP" value, then it increases the Level by 1, and the MaxXP by 20.

Then, bam.
Once you find a way to get players XP, you have a working leveling system.

Also, heres what it might look like.

--Script in StarterPack for example.

player = script.Parent.Parent
XP = player.XP
MaxXP = player.MaxXP
Level = player.Level

while true do
if XP >= MaxXP then
XP.Value = XP.Value -MaxXP
MaxXP.Value = MaxXP.Value +20
Level.Value = Level.Value +1
wait()
else
wait()
end
end

That should work pretty simply, not sure. I didn't test this at all or write the above code in a script, but i'm pretty familiar with making leveling scripts due to having to make them so many times.
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
10 Jul 2015 10:57 PM
"What if I want to make it so you need 20 more than you had before to get to the next level. for example, for level 2, you need 100, for 3, 120, for 4, 140, for 5, 160, for 6, 180"

what you need, my friend, is an algorithm; makes things so much easier

xp.Value.Changed:connect:function()
if xp.Value = xp.Value * 20 -- change to whatever; 30 is good too depending on how fast ---- players gain xp
xp.Value = xp.Value = 0
level.Value = level.Value + 1
end)
Report Abuse
JonathanW123 is online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
11 Jul 2015 11:44 AM
Thanks


I'm just here so I don't get fined
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