This is over confusing. I don’t know where to put that also there multiply characters like this and your probably frustrated. If you can try to plug it into the script. Also here what you call the character and local place of it.
local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
Your probably going to take parts of the script out the main probably is that the script totally ignores your scripts.
local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")
local changeEvent = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
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
end)
Am very sorry if am being hard or not smart.
is this your current morph script?
yes and this is what it does, its also it’s in a basic state for now.
robloxapp-20211113-1007417.wmv (1.0 MB)
you can just replace that script with this,
local function apply_morph(playercharacter, morph)
local morphhumanoid = morph:FindFirstChildOfClass("Humanoid")
local playerhumanoid = playercharacter:FindFirstChildOfClass("Humanoid")
local default_description = playerhumanoid:GetAppliedDescription()
local head = default_description.Head
local torso = default_description.Torso
local l_arm = default_description.LeftArm
local r_arm = default_description.RightArm
local l_leg = default_description.LeftLeg
local r_arm = default_description.RightArm
local morphdescription = morphhumanoid:GetAppliedDescription()
morphdescription.Head = head
morphdescription.LeftArm = l_arm
morphdescription.RightArm = r_arm
morphdescription.LeftLeg = l_leg
morphdescription.RightLeg = r_leg
morphdescription.Torso = torso
playerhumanoid:ApplyDescription(morphdescription)
end
and then whenever you want to morph the player, just do
apply_morph(game.Players.Ranger_Foxy.Character, game.ServerStorage.Mymorph)
-- you can replace the arguments with any character you want
-- first argument is for the player you want to morph
-- while second argument is for the character you want to morph the player into
No, it doesn’t work it needs the fireserver event to work.
okay, i’m going to give you an example of what i’m talking about. you have a UI which morph the player,
so in your UI, use a remote event that will fire the client input to the server whenever the client click the button in the UI, you should send the player character (the player who clicked) and the character you want to morph into.
--like this for example
local morphbutton = script.Parent --if the local script is inside the morph button
morphbutton.MouseButton1Clicked:Connect(function()
game.ReplicatedStorage.MorphEvent:FireServer(game.Players.LocalPlayer.Character, game.ServerStorage.MyMorph)
-- sends the player character and the morph character
end)
now, when the server receives the remote, morph the received character with the also received morph character
(the MorphEvent (remote event) is just an example, you can replace it with any remote event you are currently using)
in the server script that will handle the morph
local function apply_morph(playercharacter, morph)
local morphhumanoid = morph:FindFirstChildOfClass("Humanoid")
local playerhumanoid = playercharacter:FindFirstChildOfClass("Humanoid")
local default_description = playerhumanoid:GetAppliedDescription()
local head = default_description.Head
local torso = default_description.Torso
local l_arm = default_description.LeftArm
local r_arm = default_description.RightArm
local l_leg = default_description.LeftLeg
local r_arm = default_description.RightArm
local morphdescription = morphhumanoid:GetAppliedDescription()
morphdescription.Head = head
morphdescription.LeftArm = l_arm
morphdescription.RightArm = r_arm
morphdescription.LeftLeg = l_leg
morphdescription.RightLeg = r_leg
morphdescription.Torso = torso
playerhumanoid:ApplyDescription(morphdescription)
end
game.ReplicatedStorage.MorphEvent.OnServerEvent:Connect(function(plr, char, morph)
apply_morph(char, morph)
end)
==============================================================================
I recreated your server script and you should replace it with this.
you can just ignore the one above and just use this,
local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")
local changeEvent = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local function apply_morph(playercharacter, morph)
local morphhumanoid = morph:FindFirstChildOfClass("Humanoid")
local playerhumanoid = playercharacter:FindFirstChildOfClass("Humanoid")
local default_description = playerhumanoid:GetAppliedDescription()
local head = default_description.Head
local torso = default_description.Torso
local l_arm = default_description.LeftArm
local r_arm = default_description.RightArm
local l_leg = default_description.LeftLeg
local r_arm = default_description.RightArm
local morphdescription = morphhumanoid:GetAppliedDescription()
morphdescription.Head = head
morphdescription.LeftArm = l_arm
morphdescription.RightArm = r_arm
morphdescription.LeftLeg = l_leg
morphdescription.RightLeg = r_leg
morphdescription.Torso = torso
playerhumanoid:ApplyDescription(morphdescription)
end
changeEvent.OnServerEvent:Connect(function(player,chosenCharacter)
local char = player.Character
apply_morph(char, chosenCharacter)
end)
this should work now.
The button script doesn’t work but my original one does but the morph script doesn’t here is the error.
what line is that error occuring
your morph script the one that copies the player data and morphs them
line 5 i post a picture of the error
yes i know but, how is it nil? also did you paste the exact script i made or you just edited it