I want to make a GUI system where if you click on a button it morphs to a character. When i press the button it replaces my character with the new one, but my old character is still there, it also doesnt give any of the UI to the new morph.
Local script in button:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local oldCharacter = player.Character
local newCharacter = game.Lighting.Characters.Character1:Clone()
newCharacter.Name = player.Character.Name
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
player.Character = newCharacter
newCharacter.Parent = workspace
end)
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local oldCharacter = player.Character
local newCharacter = game.Lighting.Characters.Character1:Clone()
newCharacter.Name = player.Character.Name
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
player.Character = newCharacter
newCharacter.Parent = workspace
wait()
oldCharacter:Destroy()
for i, v in pairs(game:GetService("StarterGui"):GetChildren)
player.PlayerGui:FindFirstChild(v.Name):Destroy()
local clone = v:Clone()
clone.Name = "".. v.Name .."clone"
clone.Parent = player.PlayerGui
end
end)