Whenever I morph my character instantly resets/I cant move, anyone know why?

Basically, I morph after clicking a button but then i instantly reset and it returns me to the start screen.

Code:
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local PlayBtn = game:GetService("StarterGui").ScreenGui.MainFrame.Confirm
local ChangeLoadout = ReplicatedStorage:WaitForChild("GiveLoadout")
local charactermodels = ServerStorage.CharacterModels




ChangeLoadout.OnServerEvent:Connect(function(player)
	local morph = player.Loadouts.loadout.Value
	local morphchosen = ServerStorage.CharacterModels:WaitForChild(morph)
	local morphname = morphchosen.Name
	if morph == morphname then
		local morphuis = morphchosen:Clone()
		morphuis:PivotTo(player.Character:GetPivot())
		player.Character = morphuis
		morphuis.Parent = workspace
	end
end)

1 comment

0

The only problem i can think of that its not the script, when you morph into someone you break welds or the head separated from the HumanoidRootPart making the player die or if you morph it break's the Roblox animation scripts and causes it to error because you change the Roblox player references.