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.
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)
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
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.
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.
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)
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)```