Morphing Gui not working properly

Hey there! So I recently put together a morphing GUI and as for the morphing part it works really well but I came across a few issues.

  • Firstly, when you click on the morphing button it teleports the player to the location of the model and I wanted to know how I could make it so that when they morph they morph in place.

  • Secondly, when the player morphs they lose all of the items that they picked up while playing but the tools that are in StarterPack are still kept in the inventory so I wanted to know how to solve this issue.

There are 2 scripts, first one is a normal script in ServerScriptService:

--Remote Event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Load = ReplicatedStorage.Load
local ChangeChar = ReplicatedStorage.ChangeChar
--On Event Functions
game:GetService("Players").PlayerAdded:Connect(function(Player)
	local Morph = Instance.new("StringValue", script)
	Morph.Name = Player.UserId .. "'s Morph"
	Morph.Value = "DefaultAvatar"
end)

Load.OnServerEvent:Connect(function(Player, PlayerCF)
	if script[Player.UserId .. "'s Morph"].Value ~= "DefaultAvatar" then
		script[Player.UserId .. "'s Morph"].Value = "DefaultAvatar"
		Player:LoadCharacter()
	end
end)

ChangeChar.OnServerEvent:Connect(function(Player, Character,Morph, PlayerCF)
	local Humanoid = Character:WaitForChild("Humanoid")

	if script[Player.UserId .. "'s Morph"].Value ~= Morph.Name then
		script[Player.UserId.. "'s Morph"].Value = Morph.Name
		local A = Morph:Clone()
		A.Name = Player.Name
		Player.Character = A
		A.Parent = game.Workspace
	end
end)

And there is a Local Script inside the buttons that when you click on you morph into the rig:


--Remote Event
local ChangeChar = game:GetService("ReplicatedStorage").ChangeChar
--Variables
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--Mouse Click Function
script.Parent.MouseButton1Click:Connect(function()
	local Character = Player.Character
	local Morph = ReplicatedStorage.RealPlayers[script.Parent.Name]
	local PlayerCF = Character.LowerTorso.CFrame
	ChangeChar:FireServer(Character,Morph,PlayerCF)
end)

And here are pictures to where items in the script are located:

image
image

I’m new to scripting and I would love if you guide me to what exactly I should do or replace, there isn’t any video explaining it so I figured I should put it here so it’s more specific!

Example:

Check if the morph is anchored. Dont anchor it.

The morph is not anchored and i’ve checked multiple times

Check Backpack and Console before.

Use clone instead and Parent to character not morphModel.

If a player’s character has a tool equipped when their character is changed, that tool is lost.

Call Humanoid:UnequipTools() so that any equipped tools are unequipped and placed back into the player’s backpack.

How do i do that exactly? sorry for asking too much

do i put Humanoid:UnequipTools() in the server script or local script and where exactly do i put it inside the script

For in-game console, press F9.
/console also works.
And clicking display tab then clicking output boots studio console.

For clone,

Do this to whole decendant parts first. Then re-weld.

I’m kinda confused, can you explain what exactly i should do/change

Before changing character.
Try and error is also needed.

Yes I know i just wanted to know where exactly do i put this command, like which script

Okay…
Put it exactly before changing character.

which line in the script do i put it in

Try this first

ChangeChar.OnServerEvent:Connect(function(Player, Character,Morph, PlayerCF)
	local Humanoid = Character:WaitForChild("Humanoid")
	Humanoid:UnequipTools()--Since this is the only point to getting Humanoid... 

	if script[Player.UserId .. "'s Morph"].Value ~= Morph.Name then
		script[Player.UserId.. "'s Morph"].Value = Morph.Name
		local A = Morph:Clone()
		A.Name = Player.Name
		Player.Character = A
		A.Parent = game.Workspace
	end
end)

I tested it and the tool still gets lost when i change characters

Search other Morph tools and check how its working.

Try This …

--Remote Event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Load = ReplicatedStorage.Load
local ChangeChar = ReplicatedStorage.ChangeChar
--On Event Functions
game:GetService("Players").PlayerAdded:Connect(function(Player)
	local Morph = Instance.new("StringValue", script)
	Morph.Name = Player.UserId .. "'s Morph"
	Morph.Value = "DefaultAvatar"
end)

Load.OnServerEvent:Connect(function(Player, PlayerCF)
	if script[Player.UserId .. "'s Morph"].Value ~= "DefaultAvatar" then
		script[Player.UserId .. "'s Morph"].Value = "DefaultAvatar"
		Player:LoadCharacter()
		Player.Character.LowerTorso.CFrame = Player
	end
end)

ChangeChar.OnServerEvent:Connect(function(Player, Character,Morph, PlayerCF)
	local Humanoid = Character:WaitForChild("Humanoid")

	if script[Player.UserId .. "'s Morph"].Value ~= Morph.Name then
		script[Player.UserId.. "'s Morph"].Value = Morph.Name
		local A = Morph:Clone()
		A.Name = Player.Name
		Player.Character = A
		A.Parent = game.Workspace
		Player.Character:WaitForChild("LowerTorso").CFrame = PlayerCF
	end
end)
--Remote Event
local ChangeChar = game:GetService("ReplicatedStorage").ChangeChar
--Variables
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--Mouse Click Function
script.Parent.MouseButton1Click:Connect(function()
	local Character = Player.Character
	local Morph = ReplicatedStorage.RealPlayers[script.Parent.Name]
	local PlayerCF = Character.LowerTorso.CFrame
	ChangeChar:FireServer(Character,Morph,PlayerCF)
end)