-
What do you want to achieve?
I am trying to make that if “person” is in top3 on leaderboard it gives to that person name tag above head -
What is the issue?
Script breaks when I define Remote functions
(printing only number 1,2 in script below!) -
What solutions have you tried so far?
Printing
Script in workspace inside of Leaderboard:
local ds = game:GetService("DataStoreService")
local blocksODS = ds:GetOrderedDataStore("BlocksStats")
local timeUntilReset = 10
while wait(1) do
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
if timeUntilReset == 0 then
timeUntilReset = 10
for i, plr in pairs(game.Players:GetPlayers()) do
blocksODS:SetAsync(plr.UserId, plr.leaderstats.ExampleValue.Value)
end
for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = blocksODS:GetSortedAsync(false, 50)
local blocksPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(blocksPage) do
print("1")
local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
local blocks = dataStored.value
local lbtext = game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.Text
print("2")
---Add invokers---
local RebirthPos1 = game.ReplicatedStorage.LbPosFolder.Pos1:InvokeServer()
local RebirthPos2 = game.ReplicatedStorage.LbPosFolder.Pos2:InvokeServer()
local RebirthPos3 = game.ReplicatedStorage.LbPosFolder.Pos3:InvokeServer()
---Add invokers--
print("3")
---Remove Invokers---
local RebirthPos1Rem = game.ReplicatedStorage.LbPosFolder.Pos1Rem:InvokeServer()
local RebirthPos2Rem = game.ReplicatedStorage.LbPosFolder.Pos2Rem:InvokeServer()
local RebirthPos3Rem = game.ReplicatedStorage.LbPosFolder.Pos3Rem:InvokeServer()
---Remove Invokers---
print("4")
local template = script.Template:Clone()
print("5")
template.Name = name .. "Leaderboard"
template.PlrName.Text = name
template.Rank.Text = "#" .. rankInLB
print("6")
if rankInLB == 1 then
RebirthPos1 = true
print("invoked")
game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.Text = "#"..rankInLB.." ExampleValue"
game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.TextColor3 = Color3.fromRGB(255, 255, 0)
elseif rankInLB > 1 then
RebirthPos1Rem = true
elseif rankInLB == 2 then
RebirthPos2 = true
game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.Text = "#"..rankInLB.." ExampleValue"
game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.TextColor3 = Color3.fromRGB(148, 148, 148)
elseif rankInLB > 2 then
RebirthPos2Rem = true
elseif rankInLB == 3 then
RebirthPos3 = true
game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.Text = "#"..rankInLB.." ExampleValue"
game.Workspace:WaitForChild(name).Head.NameTag.LeaderboardText.TextColor3 = Color3.fromRGB(83, 41, 0)
elseif rankInLB > 3 then
RebirthPos3Rem = true
end
template.Blocks.Text = blocks
template.Parent = script.Parent
end
end)
end
end
Script inside: ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
function Pos1(player)
game.Players.Bool.Pos1.Value = true
end
game.ReplicatedStorage.LbPosFolder.Pos1.OnServerInvoke = Pos1
function Pos2(player)
game.Players.Bool.Pos2.Value = true
end
game.ReplicatedStorage.LbPosFolder.Pos2.OnServerInvoke = Pos2
function Pos3(player)
game.Players.Bool.Pos3.Value = true
end
game.ReplicatedStorage.LbPosFolder.Pos3.OnServerInvoke = Pos3