Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make your character spawn where they are supposed to??

I'm making an obby so I put a few spawn points for checkpoints. but everytime I die it just sends me to a random checkpoint and not the one right before I died, how do I fix this?

1 comment

0

Lol who upvoted this

2 answers

Make sure neutral is disaled and AllowTeamChangeOnTouch is enabled. Also try making a different team color for each checkpoint.

Insert a normal Script in each of the parts and add the code to make the player return where they left off after they died.

local spawn = script.Parent -- Find where the part is
spawn.Touched:connect(function(hit) -- When the player touches the part
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then -- If the player who touches the part is a humanoid
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Find any players
		local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData") -- Creates some sort of Data Store
		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) -- When the player respawns
				wait()
				character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0) -- Teleport to where they left off after they've touched the part in that position
			end)
		end
		
		checkpoint.Value = spawn
	end
end)

2 comments

0

nice joke ya got there

0

Doesn't seem invalid to me

This discussion is preserved as it was. New answers, comments, and votes are closed.