Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

7 comments

0

I need to go soon.

0

i think theres a leaderboard feature for mobile or for my device

0

in mobile

0

not very sure how tho because i didnt make it work and its pretty advanced

0

How about checking if the player touched the screen? Genius-

0

you are genius

0

ok, I figured out the mobile thing. How do I get the leaderboard values and change the text label to that number?

1 answer

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 :)

2 comments

0

where do I put it

0

I don't think they work

This discussion is preserved as it was. New answers, comments, and votes are closed.