I was working on a checkpoint script from a tutorial (Bc I am a beginner scripter) , and when I finished I tried to add a second row to the leaderstats (coins, rebirth, etc.) and I just couldn’t figure out how to do it.
So, How can I add second row? Or is it even possible?
Here is the script that I was working with, I tried things like copy and pasting parts of the script or even the whole script, but none of that worked.
function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
print("gah")
object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end end
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Value = 1
ack2.Parent = ack
ack.Parent = object
end end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa)
I hope it is possible to add another row/stat to the leaderstats with this script because this is really the only script I know that works.
Thanks so much! I found another script to go along with the one u showed me and it worked for checkpoints! I just had to add this part to the end of it,
Players.CharacterAdded:Connect(function(Character)
repeat wait() until Character ~= nil
local CPfolder = game.Workspace:FindFirstChild("Checkpoints")--Change "Checkpoints" to your own folder name in workspace.
local Checkpoints = CPfolder:FindFirstChild(Stage.Value)
Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(Checkpoints.Position + Vector3.new(0, 2,0))
for i,ls in pairs(CPfolder:GetChildren()) do
if ls:IsA("BasePart") then
ls.Touched:Connect(function(Touched)
if Touched.Parent:WaitForChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Touched.Parent)
if Player then
if Player.leaderstats.Stage.Value < tonumber(ls.Name) then
Player.leaderstats.Stage.Value = tonumber(ls.Name)
end
end
end
end)
end
end
end)
end)