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
3 years ago

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

local suffixes = {'','K+','M+','B+','T+','Qd+','Qn+','S+','Sp+','O+','N+','D+'}
local function format(val)
    for i=1, #suffixes do
        if tonumber(val) < 10^(i*3) then
            return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
        end
    end
end


local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local leaderboard = player:WaitForChild("leaderstats")
local Stats = leaderboard.Coins
local value = script.Parent

script.Parent.Text = format(Stats.Value)script.Parent.Parent.Parent.ValName.Text = "Cash"

Stats:GetPropertyChangedSignal("Value"):Connect(function()
    script.Parent.Text = format(Stats.Value)
end)

i suspect its the suffixes that is bugged

2 answers

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

Add a GUI and put this LocalScript inside of the TextLabel

wait(1);
local 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" };
local function v1(p1)
    for v2 = 1, #u1 do
        if tonumber(p1) < 10 ^ (v2 * 3) then
            return math.floor(p1 / (10 ^ ((v2 - 1) * 3) / 100)) / 100 .. u1[v2];
        end;
    end;
end;
local l__LocalPlayer__3 = game.Players.LocalPlayer;
while wait(0.01) do
    script.Parent.Text = v1(l__LocalPlayer__3:WaitForChild("leaderstats"):WaitForChild("Cash").Value);
end;
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 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:


game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" leaderstats.Parent = player local cash = Instance.new("IntValue", leaderstats) cash.Name = "Cash" cash.Value = 10 ---- Change value if you want

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


-- Insert Gui in StarterGui and add a textlabel. -- Move textlabel anywhere and then edit it how you like. -- Add a localscript in the textlabel and copy and paste the lines of code below into the script while wait()do local player = game.Players.LocalPlayer script.Parent.Text = "Cash: "..player:WaitForChild("leaderstats"):FindFirstChild("Cash").Value end
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 — 3y
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 — 3y
0
Just sayin Ferrarimami 120 — 3y
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 — 3y

Answer this question