My script to relocate player isnt working?

i have a script to put the player in a folder but when t he player dies, the old/dead model doesnt disappear and it moves the dead model to the folder and not the current model

game.Players.PlayerAdded:Connect(function(player)
	local char = player.Character or player.CharacterAdded:Wait()
	local hum = char:WaitForChild("Humanoid")
	local userInputService = game:GetService("UserInputService")
	local isUsingVR = userInputService.VREnabled
	if (isUsingVR) then
		hum.Died:Connect(function()
			wait(3)
				char.Parent = workspace.Players.VRPlayer
				player.RespawnLocation = workspace.VRPlayerSpawn
			for childIndex, child in pairs(char:GetChildren()) do
				if child:IsA("BasePart") and child.Name ~= "Head" and child.Name ~= "UpperTorso" then

					child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
						child.Transparency = 1
					end)

					child.Transparency = 1

				end
			end
		end)
	else
		hum.Died:Connect(function()
			wait(3)
			char.Parent = workspace.Players.NonVRPlayer
			player.RespawnLocation = workspace.VRPlayerSpawn
			
		end)
	end
end)

1 Like

Maybe try actually teleporting the characters HumanoidRootPart to VRPlayerSpawn.Position

1 Like

Is your folder in a place like ReplicatedStorage where it won’t render?

the folder is in workspace 30 letterssssss

how would i do that? can you ive me a code example

Put it in ReplicatedStorage. If you don’t want the dead player to render, then move the folder to ReplicatedStorage.

1 Like

well i want the current player inside of the folder in the workspace

I don’t understand that solution. From the looks of it, they want the dead model to disappear. That will just move the HumanoidRootPart.

1 Like

i want the non vr player to constantly be in the folder named NonVRPlayer, and i want to teleport the player to that spawnpoint when they join in and i want that to be their only spawn point

but what it does is it only keeps the dead player model in the folder and not the current model

Use Player.CharacterAdded instead to put the character in the folder and possibly position it.

2 Likes

As the player respawns, have a script teleport them to the desired location you want them to be in. There will probably be a very slight delay between spawn and teleport but it wouldn’t be interfering with gameplay.

can you help put that in my code? idk where i would put that

i would like it to only be in one code, i know im close to doing it but idk what im doing wrong

Depends on how you want to teleport the player essentially. You can do it by setting respawn location which is what I think you are trying to do which in my opinion is harder and uses more lines of code (which you don’t want) whereas teleporting the player after respawn is a more effective method at the expense of the 0.1ms delay between respawn and teleport.

Up to you though what you want to do :slight_smile:

1 Like

can you help me with teleporting the player after respawn?

Here’s the modified code:

game.Players.PlayerAdded:Connect(function(player)
	local hum = char:WaitForChild("Humanoid")
	local userInputService = game:GetService("UserInputService")
	local isUsingVR = userInputService.VREnabled
	if (isUsingVR) then
		player.CharacterAdded:Connect(function(char)
			char.Parent = workspace.Players.VRPlayer
			char:MoveTo(workspace.VRPlayerSpawn.Position + Vector3.new(0, 4, 0))
			for childIndex, child in pairs(char:GetChildren()) do
				if child:IsA("BasePart") and child.Name ~= "Head" and child.Name ~= "UpperTorso" then

					child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
						child.Transparency = 1
					end)

					child.Transparency = 1

				end
			end
		end)
	else
		player.CharacterAdded:Connect(function(char)
			char.Parent = workspace.Players.NonVRPlayer
			char:MoveTo(workspace.VRPlayerSpawn.Position + Vector3.new(0, 4, 0))
		end)
	end
end)

I’ll quickly make you an example script. Give me a minute. The reply that bcman posted is using the respawn method way which is what you are originally trying to achieve.

2 Likes

Here is a small example of what you would do to move the player after respawn. I took this from one of my games and modified it

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			print(player.Name .. " has died!")
			Player.Character:MoveTo(part.Position)
		end)
	end)
end)

This script wont work as there is a delay between respawn so you could just add a wait() or something to combat this.