Hi there. I was just wondering how i could have two leaderstats i have an script here but i dont know how i could put another leaderstat in that script bc if i do or it will be the stage leaderstat that shows up or the other leaderstat that shows up but i cant have it both could u help me?
Here is the script :
local dss = game:GetService(“DataStoreService”)
local obbyDS = dss:GetDataStore(“ObbyData”)
local checkpoints = workspace.Stages
game.Players.PlayerAdded:Connect(function(plr)
local obbyData = obbyDS:GetAsync(plr.UserId .. "-obbyStageProgress")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = plr
local stage = Instance.new("StringValue")
stage.Name = "Stage"
stage.Value = obbyData or 1
stage.Parent = ls
local char = plr.Character or plr.CharacterAdded:Wait()
char:waitForChild("HumanoidRootPart"):GetPropertyChangedSignal("CFrame")
char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
char.Humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
stage.Value = touch.Name
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end
end
end)
plr.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
hrp:GetPropertyChangedSignal("CFrame"):Wait()
hrp.CFrame = checkpoints[stage.Value].CFrame
humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
stage.Value = touch.Name
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end
end
end)
end)
Well, you can only add that if you have multiple scripts. If you do, you would place the code in the section of the script where it creates another leaderstats folder
local dss = game:GetService(“DataStoreService”)
local obbyDS = dss:GetDataStore(“ObbyData”)
local checkpoints = workspace.Stages
game.Players.PlayerAdded:Connect(function(plr)
local obbyData = obbyDS:GetAsync(plr.UserId .. "-obbyStageProgress")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = plr
local newLeader = Instance.new("StringValue") -- If its number then put NumberValue
newLeader.Name = "Put name here"
newLeader.Value = "Value"
newLeader.Parent = Is
local stage = Instance.new("StringValue")
stage.Name = "Stage"
stage.Value = obbyData or 1
stage.Parent = ls
local char = plr.Character or plr.CharacterAdded:Wait()
char:waitForChild("HumanoidRootPart"):GetPropertyChangedSignal("CFrame")
char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
char.Humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
stage.Value = touch.Name
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end
end
end)
plr.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
hrp:GetPropertyChangedSignal("CFrame"):Wait()
hrp.CFrame = checkpoints[stage.Value].CFrame
humanoid.Touched:Connect(function(touch)
if touch.Parent == checkpoints then
if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
stage.Value = touch.Name
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end
end
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
pcall(function()
obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
end)
end)
Hey! I understand your problem, all you need to do is add another value, just like you did with stages, and parent it under leaderstats which can be found under the player!
Please keep in mind the name of the value will be the name showed on the leaderstats and its value will be it’s content. If you have any questions, feel free to let me know.