I really need help with setting up the player's RespawnLocation

Hi! So im working on a game which is a combination of two types of games, Tycoon And Obby.
And i tried setting it up so the player will choose where he wants to Respawn, he could choose between two options of course, the Obby or the Tycoon. And i’ve tried to set it up so there is a Folder for all the CheckPoints, And the Character will be Moved (MoveTo) OR Respawn at the Checkpoints Name when its equals to the Stage Value. And for some reason it just doesnt work. i dont get any errors in the Output. And the RespawnLocation doesnt change. I would really like you guys to help me figure out whats wrong here. Thanks!
I decided to put everything in the “leaderstats” Script, Just so you know
the code:

	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	print(player.Name)
	local Cash = Instance.new("IntValue",leaderstats)
	Cash.Name = "Cash"
	Cash.Value = 0
	local Stage = Instance.new("IntValue",leaderstats)
	Stage.Name = "Stage"
	Stage.Value = 0
	--local obbyv =  player:FindFirstChild("ObbyV")
	--local tycoonv = player:FindFirstChild("TycoonV")
	local Cpoints = game.Workspace.CheckPoints
	local Teams = game:GetService("Teams")
	local ObbyV = Instance.new("BoolValue", player)
	ObbyV.Name = "ObbyV"
	ObbyV.Value = false
	local TycoonV = Instance.new("BoolValue", player)
	TycoonV.Name = "TycoonV"
	TycoonV.Value = false
--i dont think anything above this line has something to do with my error but maybe there is idk
player.CharacterAdded:Connect(function(char)
		
		
		local hum = char:FindFirstChild("Humanoid")
		wait()
		if ObbyV.Value == true then
			player.RespawnLocation = Cpoints[Stage.Value]
			--char:MoveTo(Cpoints[Stage.Value].Position)
		elseif TycoonV.Value == true then
			if player.Team == Teams.Red then
				player.RespawnLocation = game.Workspace.Cloud1.RedSpawn
			end 	
		end
		
		hum.Touched:Connect(function(hit)
				if hit.Parent == Cpoints then
					if tonumber(hit.Name) == Stage.Value + 1 then
						Stage.Value = Stage.Value + 1
					print("Good")
					end

				end
			end)

		--end

	end)

I also have a code which Set’s up the Player’s RespawnLocation when ever he touches the “Door” Or claims the tycoon. And it does change the Player’s RespawnLocation. Maybe it has something to do with that Code so i’ll leave it here

local door = script.Parent
local Teams = game:GetService("Teams")
local Name1 = script.Parent.SurfaceGui.TextLabel
door.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	plr.Team = Teams.Red
    plr.RespawnLocation = game.Workspace.Cloud1.RedSpawn
	door.Transparency = 0.65
	door.CanCollide = false
	door.CanTouch = false
	Name1.Text = plr.Name
end)

Thanks!

Well, the issue here is that you are setting the player’s RespawnLocation after the character loads, causing them to spawn at the most recent RespawnLocation set beforehand instead of the target one. Perhaps using PlayerAdded instead for initial spawn changes?

So if i put this whole if statement after the CharcterAdded Function. It will work?

This section is what’s causing the spawn to not be set on time (inside CharacterAdded). Maybe setting the spawn point upon death and loading in.

Edit: Also, another alternative is to set the HumanoidRootPart CFrame to the desired SpawnLocation CFrame upon characterAdded

So what you’re basically saying is that i need to set it so whenever the player dies it changes?
And for your edit. i tried using MoveTo:“the location” but it just didnt work so i’ll try it with the HumanoidRootPart. I’ll update you

Edit: So i’ll need to use Humanoid.Died am i right?

For your edit, yes, and have that also connect to a playerAdded function so that the spawn location can be initially set.

Okay wait i’ll try everything you said. i’ll update

1 Like

I Did everything i could, i dont know if i did it right but i did every single solution that i can think of and nothing worked :confused:

Would you mind telling me how you are changing their respawn values?

Using a button ofc. when ever its clicked, the values change

Then maybe you are changing stuffs from button in a local script, I recommend using remote event to do so.

hey sorry for the late reply. yea somebody else told me to do it but i dont know how…