Character doesn't respawn at chosen location

Hello, so i’ve made a game over screen for the player in the game. Basically when you die, it plays a sound and waits a few seconds before, showing the game over screen, which gives you 2 options : respawn or go back to menu. When the player selects respawn, it fires an event to the server so that the server can respawn the player using Player:LoadCharacter(). it does indeed work but the character spawns at a random position high up in the sky for some reason.
The event is a RemoteEvent located in a folder in ReplicatedStorage, the location is an attribute of the model of the map, and the client script is in the game over screen itself.

Code (Client)

--||Services
local Players = game:GetService("Players")
local Sound_Service = game:GetService("SoundService")
local Replicated_Storage = game:GetService("ReplicatedStorage")
local Tween_Service = game:GetService("TweenService")
--||Variables, UI and Sounds
local Events_Folder = Replicated_Storage:WaitForChild("FLDR_Events")
local Modules_Folder = Replicated_Storage:WaitForChild("FLDR_Modules")
local Functions = require(Modules_Folder.Functions_Module)
---------------------------------------------------------
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
---------------------------------------------------------
local Maps_Folder = workspace:WaitForChild("FLDR_Maps")
local PlrRspwn_EVNT = Events_Folder.EVNT_PlayerRespawn
---------------------------------------------------------
local GRP_Game = Sound_Service:WaitForChild("GRP_Game")
local GRP_UI = Sound_Service:WaitForChild("GRP_UI")
local Lose_SFX = GRP_Game.SFX_Lose
local UIHover_SFX = GRP_UI.SFX_UIHover
local UISelect_SFX = GRP_UI.SFX_UISelect
---------------------------------------------------------
local Game_Over = script.Parent
local Respawn_BTN = Game_Over.Respawn_Button
local Menu_BTN = Game_Over.Leave_Button
--||Function
local function onHumanoidDied()
	Lose_SFX:Play()
	task.wait(2)
	Functions:IrisTransition_In()
	task.wait(1.5)
	Game_Over.Visible = true
	Functions:IrisTransition_Out()
	Game_Over.Interactable = true
	Respawn_BTN.Activated:Connect(function()
		Game_Over.Interactable = false
		UISelect_SFX:Play()
		Functions:IrisTransition_In()
		task.wait(1.5)
		for __, Obj in ipairs(Maps_Folder:GetChildren()) do
			if Obj:IsA("Model") and string.match(Obj.Name, "Map_") then
				local Spawns_Folder = Obj:WaitForChild("FLDR_Spawns")
				local Location_Respawn = Spawns_Folder[Obj:GetAttribute("Location_Respawn")]
				task.wait(0.25)
				PlrRspwn_EVNT:FireServer(Location_Respawn)
				task.wait(1.5)
				Game_Over.Interactable = false
				Game_Over.Visible = false
				Functions:IrisTransition_Out()
			end
		end
	end)
	--[[Menu_BTN.Activated:Connect(function()
		Game_Over.Interactable = false
		UISelect_SFX:Play()
		Functions:IrisTransition_In()
		task.wait(1.5)
		Functions:IrisTransition_Out()
		Player:Kick("You have left the game!")
	end)]]
end
--||Connections
Humanoid.Died:Connect(onHumanoidDied)

Code (Server)

------------------------------------------------------------------------------
local function onRespawnEvent(Player, Location)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	Player:LoadCharacter()
	Character:PivotTo(Location.CFrame)
end
--||Connection
Events_Folder.EVNT_PlayerRespawn.OnServerEvent:Connect(onRespawnEvent)
1 Like

Try referencing the new character. All I did was swap lines 1 and 2 of the onRespawnEvent() function. My theory is that you’re setting the position of the old character and not the new/fresh one.

local function onRespawnEvent(Player, Location)
    Player:LoadCharacter()
	local Character = Player.Character or Player.CharacterAdded:Wait()
	Character:PivotTo(Location.CFrame)
end
1 Like

thanks that fixed it, but now there’s another problem : the character can’t move or jump after respawning :frowning: