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