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

How to create a leadarboard that can read data with datastore?

Asked by 3 years ago
Edited 3 years ago

I am trying to create a leaderboard and im trying to use datastore but it forgot how to use it. here is the script *database script at line 32

--/By Sabrna563
    --Variables
local Assets = script.Parent -- The Leaderboard

--Player1 Assets

local Player1 = Assets.Player1 -- Player 1
local P1Shirt = Assets.Player1.Shirt -- Shirt of Player 1
local P1Pants = Assets.Player1.Pants -- Pants of Player 1
local P1Name = Assets.Player1Box.SurfaceGui.PlayerName.Text -- TextBox of Player 1

--Player2 Assets

local Player2 = script.Parent.Player2 -- Player 2
local P2Shirt = Player2.Shirt -- Shirt of Player 2
local P2Pants = Player2.Pants -- Pants of Player 2
local P2Name = Assets.Player2Box.SurfaceGui.PlayerName.Text --TextBox of

--Player3 Assets

local Player3 = script.Parent.Player3 -- Player 3
local P3Shift = Player3.Shirt -- Player 3 Shirt
local P3Pants = Player3.Pants
local P3Name = Assets.Player3Box.SurfaceGui.PlayerName.Text


--Faces
local Face1 = script.Parent.Player1.Head.face.Texture-- Face Of Player 1
local Face2 = script.Parent.Player2.Head.face.Texture-- Face of Player 2
local Face3 = script.Parent.Player3.Head.face.Texture--Face of Player 3
--Checks If Player Should Be On Leaderboard
local DataStore = game:GetService("DataStoreService")

Also how do you count the accesories on a player? or just a number of a specific type of object in a parent. This is my script so far local NumberOfaccesories = game.Players.LocalPlayer.Character

2 answers

Log in to vote
0
Answered by 3 years ago

Hello, you can just make a simple leaderboard script, then, in another script, use DataStoreService to save the data when the player joins and leaves. from there you can setup a system to add/remove points from the player. Thanks -DragonSpawner12.

0
But how? User#36898 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Try checking for the number of accessories this way:

local numOfAccessories = 0

for _, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
    if v:IsA("Accessory") then
        numOfAccessories = numOfAccessories + 1
    end
end

print(numOfAccessories)

I think this tutorial will help you in creating your leaderboard. https://www.youtube.com/watch?v=sXpuGnVzsxw

Answer this question