Ad
Log in to vote
0

Can someone help Im having trouble scripting my gui to use leaderstats?

Asked by 1 month ago

I have tried and tried to make a script that takes all of the information from the leaderboard and puts it into to areas of a gui but it only shows the starter stats for the player when you increase the stats it does nothing for the gui

here is my code please fix it I have 3 scripts

exp displayer local EXP = game.Players.LocalPlayer.leaderstats.EXP.Value script.Parent.Text = "EXP: "..EXP

lv displayer local LV = game.Players.LocalPlayer.leaderstats.LV.Value script.Parent.Text = "LV: "..LV

exp local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild('leaderstats') local level = player:WaitForChild('LV') local xp = player:WaitForChild('EXP')

level.Changed:connect(function() if xp.Value < 100level.Value then xp.Value = xp.Value - 100level.Value level.Value = level.Value + 1 end end)

it shows the base stats but if I change the leader stats the gui does not change please help

1 answer

Log in to vote
0
Answered by 1 month ago

Lets say that for each leaderstats value, there is a textlabel in a gui

lvl = game.Players.LocalPlayer.leaderstats.Level.Value

while true do
wait(0.1)
script.Parent.Text = "Level " .. lvl
exp = game.Players.LocalPlayer.leaderstats.EXP.Value

while true do
wait(0.1)
script.Parent.Text = exp .. " EXP"
local player = game.Player.LocalPlayer.leaderstats
expneeded = expneeded * player.Level.Value -- doubles the amount of xp needed everytime the player ranks up.

while true do
wait(0.1)
if player.EXP.Value >= expneeded then
player.Level.Value = player.Level.Value + 1 --increases level
player.EXP.Value = 0 --resets exp value
expneeded = expneeded + 500 --increases the exp needed to rank up

also if using game.Players.LocalPlayer you must put the code into a localscript or it will not work in a server/online game

you can make this one script if you just change script.Parent to the name of the textlabels. The last script can be put anywhere in the starterpack in a local script.

Ad

Answer this question



Ad