Hi, I have a problem because in output I get an error: leaderstats is not a valid member of Player
script:
local RepStorage = game:GetService(“ReplicatedStorage”)
local StageEvent = RepStorage:WaitForChild(“Stage”)
game.Players.PlayerAdded:Connect(function(player)
local Stage = player.leaderstats:FindFirstChild("Stage")
local CurrentStage = Instance.new("IntValue", player)
CurrentStage.Name = "CurrentStage"
CurrentStage.Value = Stage.Value
CurrentStage.Parent = player
CurrentStage.Value = Stage.Value
Stage.Changed:Connect(function()
if CurrentStage.Value ~= Stage.Value then
CurrentStage.Value = Stage.Value
end
end)
end)
StageEvent.OnServerEvent:Connect(function(player, action)
local char = game.Workspace:FindFirstChild(player.Name)
local CurrentStage = player:WaitForChild(“CurrentStage”)
local Stage = player:WaitForChild(“leaderstats”):FindFirstChild(“Stage”)
local function moveStage()
local checkPoint = game.Workspace.Stages:FindFirstChild(tostring(player.CurrentStage.Value))
local checkPosition = checkPoint.Position
char:MoveTo(checkPosition)
end
if action == "<" then
CurrentStage.Value = CurrentStage.Value - 1
if tonumber(CurrentStage.Value) < 1 then
CurrentStage.Value = Stage.Value
end
moveStage()
elseif action == ">" then
CurrentStage.Value = CurrentStage.Value + 1
if tonumber(CurrentStage.Value) > tonumber(Stage.Value)then
CurrentStage.Value = 1
end
moveStage()
end
end)
please help me