Custom Character Keeps Respawning Me?

It morphs me fine but then respawns me after so long what could be the problem? It had Upper Torso, LowerTorso and humanoid I have no idea why it keeps respawning me.
–Local Script
plyr = game.Players.LocalPlayer

repeat wait() until plyr.Character

char = plyr.Character

cam = workspace.CurrentCamera

button = workspace:WaitForChild(“button”)

abutton = button:WaitForChild(“button”)

cd = abutton:WaitForChild(“transform”)

rs = game:GetService(“ReplicatedStorage”)

event = rs:WaitForChild(“MechEvent”)

pn = char.Name

cd.MouseClick:connect(function()

event:FireServer()

local mech = workspace:WaitForChild(pn…“Mech”)

cam.CameraSubject = mech.UpperTorso

end)

—ServerSide

rs = game:GetService(“ReplicatedStorage”)

event = rs:WaitForChild(“MechEvent”)

mech = rs:WaitForChild(“StarterCharacter”)

event.OnServerEvent:connect(function(plyr)

local mech2 = mech:Clone()

mech2.Parent = game.Workspace

mech2.Name = plyr.Character.Name…“Mech”

plyr.Character = mech2

end)

I figured it out it wasnt a scripting related problem im very sorry, I had the humanoid set to r6 but its r15

May I also point out that you can use codeblocks to format your code better.

Simply put 2 sets of 3 backticks (`) and put your code in between.

This is a test

Also, if your question is solved, please include [SOLVED] in the topic title

Modified the script’s variables and readability, please use codeblocks next time.

-- Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = game.Players.LocalPlayer; repeat wait() until player.Character
local character = player.Character
local camera = workspace.CurrentCamera

local button = workspace:WaitForChild("button")
local abutton = button:WaitForChild("button")
local cd = abutton:WaitForChild("transform")

local event = ReplicatedStorage:WaitForChild(“MechEvent”)

cd.MouseClick:Connect(function()
	event:FireServer()
	local mech = workspace:WaitForChild(player.Name .. "Mech")
	camera.CameraSubject = mech.UpperTorso
end)

-- Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local event = ReplicatedStorage:WaitForChild("MechEvent")
local mech = ReplicatedStorage:WaitForChild("StarterCharacter")

event.OnServerEvent:Connect(function(player)
	local mech2 = mech:Clone()
	mech2.Name = player.Name .. "Mech"
	mech2.Parent = workspace
	player.Character = mech2
end)

No scripting error was detected. It was probably character issues as aforementioned by the author(or OP).

@Raretendoblox You don’t need to include it to the title. Just mark the solution on one of the replies.

thankyou sorry about the codes format guys!