What solutions have you tried so far? I couldnt find anything
Here is my codes:
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"
local Checkpoint = Instance.new("IntValue", leaderstats)
Checkpoint.Name = "Checkpoint"
Checkpoint.Value = 1
Player.CharacterAdded:Connect(function(Character)
repeat wait() until Player.Character ~= nil
local checkpoint = game.Workspace.Checkpoints:FindFirstChild(Checkpoint.Value)
Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,2,0))
end)
end)
local Checkpoints = script.Parent
for i,v in pairs(Checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player.leaderstats.Checkpoint.Value < tonumber(v.Name) then
player.leaderstats.Checkpoint.Value = tonumber(v.Name)
end
end
end
end)
end
end
So basically i can change the value but it dosent work, in leaderboard im in Checkpoint 1 but in game im in Checkpoint 4, how can i fix that
Make sure you are handling the second script via server-sided Script. It makes no sense if you are using LocalScripts to do it because LocalScripts will only work for the player’s client. The leaderboard you are using for showing players’ leader stats won’t update the checkpoint value because it is just for the client, it is only for you. But if you do it in a server-sided script, it will also update and save your value.
So this script must be executed via server. Put this script in ServerScriptService.
for i, v in pairs (game.Workspace.Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
local CheckpointValue = player:WaitForChild("leaderstats").Checkpoint.Value
if player then
if CheckpointValue + 1 == tonumber(v.Name) then
CheckpointValue = tonumber(v.Name)
end
end
end)
end
Delete TouchHandler script which is in the Checkpoints folder and insert a new script in ServerScriptService. Paste this script into it.
Checkpoints klasörünün içindeki TouchHandler’ı sil ve ServerScriptService'e bir kod bloğu açıp bu kodu onun içine yerleştir.
for i, v in pairs (game.Workspace.Checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if (tonumber(Checkpoint.Value + 1)) == tonumber(v.Name) then
Checkpoint.Value = tonumber(v.Name)
end
else
return false
end
end)
end
end
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Checkpoint = Instance.new("IntValue", leaderstats)
Checkpoint.Name = "Checkpoint"
Checkpoint.Value = 1
repeat
wait()
until player.CharacterAdded
for i, v in pairs (game.Workspace.Checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if (tonumber(Checkpoint.Value + 1)) == tonumber(v.Name) then
Checkpoint.Value = tonumber(v.Name)
end
else
return false
end
end)
end
end
end)
Okay try this one and don’t define any variable. It’ll work now.
Bunu SpawnPointScript’e koy çünkü az önce kendime göre yapmıştım. O yüzden çalışmamış olabilir. local Checkpoint yazmışsın. Oradaki kastım Checkpoints klasörü değildi, oyuncunun klasöründeki değerdi. O yüzden checkpoint diye bir değişken atadığın için çalışmadı. Şimdi buna hiçbir şey yazmadan koyabilirsin. Eminim şimdi çalışacaktır.
Eğer SpawnPointScript’in içindeki sadece yukarıdaki gibiyse onu silip aşağıdakini ekle.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Checkpoint = Instance.new("IntValue", leaderstats)
Checkpoint.Name = "Checkpoint"
Checkpoint.Value = 1
repeat
wait()
until player.CharacterAdded
player.CharacterAdded:Connect(function(Character)
repeat wait() until player.Character ~= nil
local checkpoint = game.Workspace.Checkpoints:FindFirstChild(Checkpoint.Value)
Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,2,0))
end)
for i, v in pairs (game.Workspace.Checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if (tonumber(Checkpoint.Value + 1)) == tonumber(v.Name) then
Checkpoint.Value = tonumber(v.Name)
end
else
return false
end
end)
end
end
end)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Checkpoint = Instance.new("IntValue", leaderstats)
Checkpoint.Name = "Checkpoint"
Checkpoint.Value = 1
repeat
wait()
until player.CharacterAdded
local part = game.Workspace.Part
part.Touched:Connect(function(hit)
local checkPlayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if checkPlayer then
Checkpoint.Value = 0
end
end)
end)
I think you are using a script under the part because when I checked in the studio there was no problem. I think you should check if there is a Script under the part. It must have affected your value.
No i made CellatBaba xd from 0 animation face clothing all of these stuff. So Cellat doesnt have any code like that, but i have this code in my other script