GUI given to player when they morph into certain character

How do I make it so when they change character it finds the screen Gui with the morphs name and clones it and gives it to the player. I have no clue how to make it do it. Also, I don’t want them to appear for all morphs.
Capture

Here is the script that controls all the morph changes.


local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")

changeEvent.OnServerEvent:Connect(function(player,chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end


		newChar.Name = player.Name
		player.Character = newChar

		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = workspace
		--game.ReplicatedStorage.bobSkills:Clone().Parent = player.PlayerGui
	else
		warn("character doesnt exist or something went wrong.")
	end
end)
2 Likes

You might be able to move the GUI to be a child as the character model and add this somewhere to your script:

newChar.GUI.Enabled = true

Edit: Name all the GUI’s: “GUI”.

1 Like

when u char them add code to clone the gui into playgui in their playermodel.

example:

[gui]:Clone().Parent = [player].PlayerGui

if the gui is in startergui, try this

[player].PlayerGui.[gui].Enabled = true -- Or whatever the property is that hides the gui. If a frame is hidden it will be .Visible not Enabled and you would do .[gui].[Frame].Visible = true

hope this helps!

I mean when they morph into a new character Ex: bob, bob’s GUI pops up same with john the problem is that I don’t know how to make the GUI for certain characters like bob and john they have two different GUI. The script is for every morph, not one. The script needs to find the character’s name and grab their GUI with their name on it. sorry if it’s confusing.

yes, when u char them add code to clone the gui into playgui in their playermodel.

You can’t i tried that the best idea i have is to find the morph name Ex: bob and then name the GUI bob and make the script get the GUI name after the morph and make it visible or move it the player by cloning it. I have no clue to how to type this into code.

local GUIClone = newChar.GUI:Clone()
GUIClone.Parent = player.PlayerGui

This will move it to the player’s GUIs just like StarterGui does.

Where do i put it in the script?

Try this and let me know if it works or doesn’t work.

local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")

changeEvent.OnServerEvent:Connect(function(player,chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end


		newChar.Name = player.Name
		player.Character = newChar


        local GUIClone = newChar.GUI:Clone()
        GUIClone.Parent = player.PlayerGui


		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = workspace
		--game.ReplicatedStorage.bobSkills:Clone().Parent = player.PlayerGui
	else
		warn("character doesnt exist or something went wrong.")
	end
end)

it does not work the GUI doesn’t go into the player.

It goes into the player’s GUI.

no it doesn’t there’s no errors too

Can I see a screen shot of the workspace with the character model and its children?

Capture

Is the GUI enabled and visible?

yes. it only seems to work until the part of giving it to the player

Ohhh wait, I was looking more at your script. Try moving the code lines I gave you above these two lines: newChar.Name = player.Name player.Character = newChar

Revised:

local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")

changeEvent.OnServerEvent:Connect(function(player,chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end

        local GUIClone = newChar.GUI:Clone()
        GUIClone.Parent = player.PlayerGui

		newChar.Name = player.Name
		player.Character = newChar


		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = workspace
		--game.ReplicatedStorage.bobSkills:Clone().Parent = player.PlayerGui
	else
		warn("character doesnt exist or something went wrong.")
	end
end)```
1 Like

assuming you have not made any changes since first post

you could change the UI name to [character name]‘UI’ and make a small change to the commented out part;

--game.ReplicatedStorage.bobSkills:Clone().Parent = player.PlayerGui

to

game.ReplicatedStorage[chosenCharacter..'UI']:Clone().Parent = player.PlayerGui
3 Likes

doesn’t work it still fails to give the player the GUi.

Thank you finally i could put this in, so i can get farther in my work. The script works!