Hello, I have problem with checkpoint system to my game. I think succesfully connected two scripts, but you guys should check it. Now my problem is with checkpoint pad, which should player spawn there and add next checkpoint to leaderboard... im using checkpoint leaderboard gui.
Here is script with my leaderboard, i know it's long script:
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("IntValue",player)
leaderstats.Name = "leaderstats"
local points = Instance.new("NumberValue",leaderstats)
points.Name = "Points"
points.Value = 0
local P = game.StarterGui.Points.Frame.Point
P.Text = " "..points.Value
end)
function oa (object)
local player = game.Players:GetPlayerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Checkpoints.Value)
print ("Run")
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 leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
local checkpoint = Instance.new("NumberValue")
checkpoint.Name = "Checkpoints"
checkpoint.Value = 1
checkpoint.Parent = leaderstats
leaderstats.Parent = object
local C = game.StarterGui.Checkpoints.Frame.Check
C.Text = " "..checkpoint.Value
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa)
Here is script with pad:
function cp (hit)
if hit.Parent ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
if player.leaderstats.Checkpoints.Value == script.Parent.Name - 1 then
local s = hit.Parent:FindFirstChild("Humanoid")
if s ~= nil then
if s.Health ~= 0 then
player.leaderstats.Checkpoints.Value = script.Parent.Name
end
end
end
end
end
end
script.Parent.Touched:connect(cp)
So please help me fix it or just say what's wrong is with this.
