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 4 years ago
Edited 4 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

01--/By Sabrna563
02    --Variables
03local Assets = script.Parent -- The Leaderboard
04 
05--Player1 Assets
06 
07local Player1 = Assets.Player1 -- Player 1
08local P1Shirt = Assets.Player1.Shirt -- Shirt of Player 1
09local P1Pants = Assets.Player1.Pants -- Pants of Player 1
10local P1Name = Assets.Player1Box.SurfaceGui.PlayerName.Text -- TextBox of Player 1
11 
12--Player2 Assets
13 
14local Player2 = script.Parent.Player2 -- Player 2
15local P2Shirt = Player2.Shirt -- Shirt of Player 2
View all 32 lines...

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 4 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 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Try checking for the number of accessories this way:

1local numOfAccessories = 0
2 
3for _, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
4    if v:IsA("Accessory") then
5        numOfAccessories = numOfAccessories + 1
6    end
7end
8 
9print(numOfAccessories)

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

Answer this question