Really, I need help guys, I have made a checkpoint script for my game (to tell the truth, I edited a checkpoint script from the toolbox), But some times this works and sometimes not!
local spawn = script.Parent
check=false
function Checkpoint(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Model", game.ServerStorage)
checkpointData.Name = "CheckpointData"
end
local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
if not checkpoint then
checkpoint = Instance.new("ObjectValue", checkpointData)
checkpoint.Name = tostring(player.userId)
player.CharacterAdded:connect(function(character)
wait()
character:WaitForChild("Torso").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end)
end
checkpoint.Value = spawn
if check==false then
check=true
script.Parent.Sound:play()
script.Parent.ParticleEmitter.Enabled=true
wait(3)
script.Parent.ParticleEmitter.Enabled=false
end
end
end
spawn.Touched.connect:Checkpoint
When works, spawns in the start spawn first and then the player is teleported to the checkpoint.
Please Please Help Me..... |