|
| 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 |
|
|
| 10 Jul 2015 09:42 PM |
b
I'm just here so I don't get fined |
|
|
| Report Abuse |
|
|
| 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 |
|
|
| 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 |
|
|
| 11 Jul 2015 11:44 AM |
Thanks
I'm just here so I don't get fined |
|
|
| Report Abuse |
|