this keeps changing everyones leaderstat if 1 player hits the part, i want it to only happen to the specific player that hits the part.
local FinishDetector = workspace:WaitForChild("FinishThing"):WaitForChild("Detector")
local hasWon = false
FinishDetector.Touched:Connect(function(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player and not hasWon then
local checkpoint1 = CheckpointsFolder:FindFirstChild("1")
if checkpoint1 then
Wins.Value = Wins.Value + 1
player.leaderstats:FindFirstChild("🕹️Stage").Value = 1
hasWon = true
player.Character:SetPrimaryPartCFrame(checkpoint1.CFrame)
wait(5)
hasWon = false
myDataStore:SetAsync(player.UserId, {Stage = 1, Wins = Wins.Value, Deaths = Deaths.Value})
end
end
end)