Other clients not being able to see animations

Hey DevForum, A few days ago I scripted a morphing script where it would let you keep your own animations and bodycolor.

Script
	local Animate = Player.Character.Animate:Clone()
	local BodyColors = Player.Character["Body Colors"]:Clone()
	
	local charClone = Character:Clone()
	Character:Destroy()
	charClone.Name = Player.Name
	charClone.PrimaryPart.CFrame = Player.Character.PrimaryPart.CFrame
	Player.Character = charClone
	
	local rootPart = charClone:FindFirstChild("HumanoidRootPart")
	local plrRoot = Player.Parent:FindFirstChild("HumanoidRootPart")
	
	if rootPart and plrRoot then
		rootPart.CFrame = plrRoot.CFrame
	end
	
	charClone.Parent = workspace
	
	Animate.Parent = charClone
	BodyColors.Parent = charClone

Problem is after setting the Animate script’s parent it makes it so only the client that’s morphing able to see it. I have tried doing regular scripts but it makes the animations play weirdly. This is a serverside script.

You can’t change parents with a local script, unless you want said thing to only execute locally.

1 Like

How would I go by doing this then?

Now that I think about it I also had this issue in the past, where using multiple animation scripts (even if handled by the server to parent and clone), only worked locally.

I suggest making it so when a morphing happens, one animation script changes its behavior depending on something (like a string value).

If the string value has, let’s say, “zombie” in it, the animation script will load in a different set of animations.

1 Like

You should use localscripts, i’ll explain more on the solution.

It doesn’t matter if it’s a localscript or a serverscript, animations will be always able to play, since the client (the player’s perspective) launches more quicker, the animation would be more stable and healthy, since the server (everyone’s perspective) script is too busy with the server, it would be too slow to load the animation’s stability, here’s a solution i can provide.

You should insert a clone of the player’s animate in the StarterPlayerScripts in the explorer, this way the player will spawn with their own animation and bodycolors but the thing is the old character is still loaded in so the animations are still jerky, load their characters and save their backpack, guis. When they load, give the backpack descendants and visible guis back.

If it seems too complex you should place the animate and bodycolors inside the parent just like you did, if that doesn’t work…

What about this? Why is it getting the parent of the player?
image

You should probably give us the error output, if there’s none, write a print() function in one of the lines and see if they print or not, if they don’t you can probably try to figure out the issue.

Sorry if some solutions i gave you is what you’ve tried earlier since i’m a bit busy.

1 Like

Inserting their Animate script on StarterPlayerScripts won’t do much as I will not be resetting the players when they morph

I’m not sure, I didn’t write this code, I got it from a tutorial on youtube and changed it up a whole lot (only part I’m using from their script is setting the NPC as the player’s character), that part doesn’t make sense I’ve never really paid attention to it I’ll remove it.

There are no errors in output.

Still haven’t found the solution to this so I’ll bump it up.

Found a solution:
Had to change the way of morphing but it works.

function module:Morph(Player,Character,BodyType)
	BodyType = BodyTypes[BodyType]:Clone()
	BodyType.Parent = workspace
	Character = Costumes[Character]:Clone()
	Character.Parent = workspace
	
	for _,accessory in pairs(Player.Character:GetChildren()) do
		if accessory:IsA("Accessory") then
			accessory:Destroy()
		elseif accessory:IsA("Shirt") or accessory:IsA("Pants") then
			accessory:Destroy()
		end
	end
	
	if Player.Character.Head:FindFirstChildOfClass("Decal") then
		Player.Character.Head:FindFirstChildOfClass("Decal"):Destroy()
	end
	
	for _,accessory in pairs(Character:GetChildren()) do
		if accessory:IsA("Accessory") then
			local newaccessory = accessory:Clone()
			newaccessory.Parent = workspace
			newaccessory.Parent = Player.Character
		elseif accessory:IsA("Shirt") or accessory:IsA("Pants") then
			local clothing = accessory:Clone()
			clothing.Parent = Player.Character
		end
	end
	
	BodyType.PrimaryPart.CFrame = Player.Character.PrimaryPart.CFrame
	
	for _,BodyPart in pairs (Player.Character:GetChildren()) do
		if BodyPart:IsA("BasePart") and BodyPart.Name ~= "HumanoidRootPart" then
			local EnumBodyPart = Player.Character.Humanoid:GetBodyPartR15(BodyPart)
			local NewBodyPart = BodyType:FindFirstChild(BodyPart.Name)
			local EnumNewBodyPart = BodyType.Humanoid:GetBodyPartR15(NewBodyPart)
			Player.Character.Humanoid:ReplaceBodyPartR15(EnumBodyPart,NewBodyPart)
			BodyPart:Destroy()
		end
	end
	
	BodyType:Destroy()
	
	Character.Head:FindFirstChildOfClass("Decal"):Clone().Parent = Player.Character.Head
	
	Character:Destroy()
end

Now instead of re-parenting the Animate script I just replace the limbs and move the accesories/clothes/face to the player’s character.

1 Like