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

why is this leaderstats script unreliable?

Asked by 4 years ago

sometimes the deaths leaderboard appears and sometimes it isnt there, why does this happen?

01local dss = game:GetService("DataStoreService")
02 
03local deathsDataStore = dss:GetDataStore("deathsDataStore")
04 
05game.Players.PlayerAdded:Connect(function(player)
06 
07    local leaderstats = player:WaitForChild("leaderstats")
08 
09    local deaths = Instance.new("IntValue")
10    deaths.Name = "Deaths"
11    deaths.Parent = leaderstats
12 
13    local data
14    local success, errormsg = pcall(function()
15        data = deathsDataStore:GetAsync(player.UserId.."-deaths")
View all 45 lines...
0
Just wondering, is this the full script? VVoretex 146 — 4y
0
Maybe because the leaderstat's parent isn't specified. The leaderstat's parent should always be the player unless I'm blind and I don't see where it is specified. XEpicGoldenBoyX 35 — 4y
0
@VortexGamerPlayerYT yes Fr0stPh3onix 79 — 4y

1 answer

Log in to vote
0
Answered by
99Of19 -10
4 years ago

you have to call the function by usnig WaitForChild

local part = script.Parent.WaitForChild(Connect:function[player])

print("NameOfChild").ReplicatedStorage = Vector3.new("Really red") end)

functionofWaitForChild()

0
i dont understand Fr0stPh3onix 79 — 4y
0
It's actually really easy. you need to locate the function in this case pcall. then you use WaitForChild to attempt to call index 99Of19 -10 — 4y
Ad

Answer this question