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

How do I relocate a player's character to the obby spawns in my spawn script?

I've tried many ways around it, and in this sample I have my most recent attempt.

game.Players.PlayerAdded:connect(function(plr)
	local stat = Instance.new("Model")
	stat.Name = "leaderstats"
	stat.Parent = plr
	print(stat.Parent)
	
	local stat2 = Instance.new("NumberValue")
	stat2.Name = "Stage"
	stat2.Parent = stat
	print(stat2.Parent)
end)

for i,v in pairs(game.Workspace:GetChildren()) do
	if v.ClassName == "Part" then
		if v:FindFirstChild('Value') then
			print(v.Value.Value)
			game.Players.PlayerAdded:connect(function()
				v.Name = ("Spawn" .. v.Value.Value)
			end)
			v.Touched:connect(function(hit)
				if hit.Parent:FindFirstChild('Humanoid') then
					if hit.Parent.Humanoid.Health ~= 0 then
						if v.Value.Value == game.Players.LocalPlayer.leaderstats.Stage.Value+1 then
							game.Players.LocalPlayer.leaderstats.Stage.Value = v.Value.Value
							if v.Value == game.Players.LocalPlayer.leaderstats.Stage.Value then
								game.Players.LocalPlayer.CharacterAdded:connect(function(chr)
									wait(0.1)
									game.Players.LocalPlayer.Character:MoveTo(v.Position+Vector3.new(0, 3, 0))
								end)
							end
						end
					end
				end
			end)
		end
	end
end

I am attempting to get the game to wait for the character to load and it to the spawn. (as seen line 23 - 28)

1 answer

An easy answer to this is to create value data points to each spawn, and if the value point is equal to the data value point of player then cFrame the torso of rhe player to the specific value of the spawn.

Ex. if character spawnvalue equals 0, then CFrame player to spawn and you would you this as a on character added function. Also, if the user touches the whole spawn/part, and the character is not dead then the value moves to the spawn value that is touched.

that would be inside the touched event inside the spawn/part. Instead of having to CFrame though,you could use the MoveTo property of Model and do exactly the same.

Edit: another note to that, what you are missing is the touched event for the part. And the list of spawns in workspace.

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