Hello everyone!

Ive been making an obby game where the player has to do certain jumps and such to move on. Each stage has a spawn, and when you die, you will spawn on the stage's spawn block.

I have a script that when the player touches the "win pad", it will put the player on the new spawn for the new stage, and and set the respawn location in the player to that new spawn.

stage = string.sub(script.Parent.Parent.Name, 6, -1)

script.Parent.Touched:Connect(function(t)
	if t.Parent:FindFirstChild("Humanoid") then
		t.Parent.Humanoid.WalkSpeed = 16
		local newstage = tonumber(stage) + 1
		if newstage == 11 then
			print("You beat the pack!")
		else
			t.Parent.HumanoidRootPart.CFrame =
				script.Parent.Parent.Parent.Parent:FindFirstChild("Stage " .. tostring(newstage)).StageSpawn.CFrame
			game.Players:GetPlayerFromCharacter(t.Parent).RespawnLocation = script.Parent.Parent.Parent.Parent:FindFirstChild("Stage " .. tostring(newstage)).StageSpawn
			print(game.Players:GetPlayerFromCharacter(t.Parent).RespawnLocation.Parent.Name) -- prints the next stage
		end
	end
end)

Each stage's spawn also has a script that updates the respawn location to its stage

script.Parent.Touched:Connect(function(t)
	if t.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(t.Parent)
		plr.RespawnLocation = script.Parent
		print(plr.RespawnLocation.Parent.Name) -- prints the stage the player is currently on.
	end
end)
~~~~~~~~~~~~~~~

I also have a script that sets the respawn location to the first stage when the player joins, so that they dont spawn in a further stage

game.Players.PlayerAdded:Connect(function(plr) plr.RespawnLocation = workspace:FindFirstChildOfClass("Folder")["Stage 1"].StageSpawn end)



I used prints to see if the respawn was being set tp the correct spawn, and it all is normal; the spawns are setting the players respawn location to themselves (the instance), and the "win pad" also sets the respawn location to the next stage. For some reason, I keep respawning in the 1st stage's spawn. Can someone help me?

Any help is appreciated :)

1 comment

0

I honeslty feel bad for you. Ill try to help