Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do you make a gui connect to the leaderstats??

Asked by
Hafrew 16
4 years ago

Very oofed im trying to make a gui that shows your cash but i cant seem to do it. my script:

01local suffixes = {'','K+','M+','B+','T+','Qd+','Qn+','S+','Sp+','O+','N+','D+'}
02local function format(val)
03    for i=1, #suffixes do
04        if tonumber(val) < 10^(i*3) then
05            return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
06        end
07    end
08end
09 
10 
11local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
12local leaderboard = player:WaitForChild("leaderstats")
13local Stats = leaderboard.Coins
14local value = script.Parent
15 
16script.Parent.Text = format(Stats.Value)script.Parent.Parent.Parent.ValName.Text = "Cash"
17 
18Stats:GetPropertyChangedSignal("Value"):Connect(function()
19    script.Parent.Text = format(Stats.Value)
20end)

i suspect its the suffixes that is bugged

2 answers

Log in to vote
0
Answered by
Gogulsky 129
4 years ago

Add a GUI and put this LocalScript inside of the TextLabel

01wait(1);
02local u1 = { "", "K", "M", "B", "T", "Qd", "Qn", "Sx", "Sp", "Oc", "N", "De", "UDe", "DDe", "TDe", "QdDe", "QnDe", "SxDe", "SpDe", "OcDe", "NvDe", "Vgn", "UVg", "DVg", "TVg", "qtV", "QnV", "SeV", "SPG", "OVG", "NVG", "TGN", "UTG", "DTG", "tsTG", "qtTG", "QnTG", "ssTG", "SpTG", "OcTG", "NoAG", "UnAG", "DuAG", "TeAG", "QdAG", "QnAG", "SxAG", "SpAG", "OcAG", "NvAG", "CT" };
03local function v1(p1)
04    for v2 = 1, #u1 do
05        if tonumber(p1) < 10 ^ (v2 * 3) then
06            return math.floor(p1 / (10 ^ ((v2 - 1) * 3) / 100)) / 100 .. u1[v2];
07        end;
08    end;
09end;
10local l__LocalPlayer__3 = game.Players.LocalPlayer;
11while wait(0.01) do
12    script.Parent.Text = v1(l__LocalPlayer__3:WaitForChild("leaderstats"):WaitForChild("Cash").Value);
13end;
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Well if you're just trying to make a UI that shows the value "Cash" here's how to do it.

LEADERSTAT SCRIPT:

1game.Players.PlayerAdded:Connect(function(player)
2 
3local leaderstats = Instance.new("Folder",player)
4leaderstats.Name = "leaderstats"
5leaderstats.Parent = player
6 
7local cash = Instance.new("IntValue", leaderstats)
8cash.Name = "Cash"
9cash.Value = 10 ---- Change value if you want

=========================================================================

1-- Insert Gui in StarterGui and add a textlabel.
2-- Move textlabel anywhere and then edit it how you like.
3-- Add a localscript in the textlabel and copy and paste the lines of code below into the script
4while wait()do
5    local player = game.Players.LocalPlayer
6    script.Parent.Text = "Cash: "..player:WaitForChild("leaderstats"):FindFirstChild("Cash").Value
7end
0
If you have any problems comment back and i'll get back to you when I can. If it works and it's what you wanted then if you can click is as the correct answer that'd be great. Cya Nitrolux200 62 — 4y
0
You don't have to set the Parent twice. You can either do ("IntValue", leaderstats) or cash.Parent = leaderstats. Settings it two times doesn't make any sense Ferrarimami 120 — 4y
0
Just sayin Ferrarimami 120 — 4y
0
^ The parental argument of the Instance constructor was deprecated, it is recommended you just set the parent manually, and after all property modifications. Ziffixture 6913 — 4y

Answer this question