Ad
Log in to vote
0

How do I change Leaderboard values to gui for mobile users?

Asked by 2 days ago

For example somebody on the Leaderboard has 43 kills but they can't see it because they are mobile. So I want to know how to make a gui that shows their kills that gets information from the Leaderboard values. Please explain where to put things as I'm a little new to scripting like this.

This is the Leaderstats script, it's in SeverScriptService:

function playerJoined(player) local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats"

local kills = Instance.new("NumberValue",leaderstats)
kills.Name = "Kills"
kills.Value = 0

local Deaths = Instance.new("NumberValue",leaderstats)
Deaths.Name = "Deaths"w
Deaths.Value = 0

player.CharacterAdded:Connect(function(character)
    local humanoid = character:FindFirstChild("Humanoid")
    humanoid.Died:Connect(function()
        Deaths.Value = Deaths.Value + 1 


        local tag = humanoid:FindFirstChild("creator")
        local killer = tag.Value
        if tag and killer then
            local hum = game.Players:FindFirstChild("humanoid")
            killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
        end
    end)    
end)

end

game.Players.PlayerAdded:Connect(playerJoined)

0
I need to go soon. Roblox28721 5 — 2d
0
i think theres a leaderboard feature for mobile or for my device Xapelize 1835 — 2d
0
in mobile Xapelize 1835 — 2d
0
not very sure how tho because i didnt make it work and its pretty advanced Xapelize 1835 — 2d
View all comments (3 more)
0
How about checking if the player touched the screen? Genius- Roblox28721 5 — 2d
0
you are genius Xapelize 1835 — 2d
0
ok, I figured out the mobile thing. How do I get the leaderboard values and change the text label to that number? Roblox28721 5 — 2d

1 answer

Log in to vote
0
Answered by
7777ert 49
2 days ago
Edited 2 days ago

You can first make a TextLabel and set the Text property to 'Kills: 0'

Then add a local script inside the Textlabel

type in the code:

while wait() do
    script.Parent.Text = "Kills: "..tostring(game.Players.LocalPlayer.leaderstats.Kills.Value)
end

the above code checks the value of Kills in your leaderboard every 0.1 seconds. And it will turn the value into a string and display it to mobile players.

Hope this helps :)

Edit: just found a better way doing so. you can use the changed event instead of while loop:

local kills = game.Players.LocalPlayer.leaderstats.Kills
kills.Changed:Connect(function()
    script.Parent.Text = "Kills: "..tostring(kills.Value)
end)

the changed event fires when any properties of Kills changed. I still havent test if this code works but you can have a try :)

0
where do I put it Roblox28721 5 — 23h
0
I don't think they work Roblox28721 5 — 23h
Ad

Answer this question