Animate script not replicating to other clients

so i made this script which clones an animate script and pastes it into the player, the animations play but dont replicate to other clients, what can i do to fix?


plr.CharacterAdded:Connect(function()
	local newAnimate = script.Animate:Clone()
	newAnimate.Parent = plr.Character
end)

robloxapp-20230420-1413060.wmv (1.5 MB)
robloxapp-20230420-1413107.wmv (3.6 MB)
image

You’re trying to clone the “Animate” using LocalScript which will only affect yourself.

1 Like

So i do so in the serverscript?

1 Like

Yes, and also put it on StarterCharacterScripts.
Edit : Forgot to read your code

Birdie, i have ascript which switches the player’s character, i forgot to mention that, here’s that script:

local function respawnPlayer(plr, modelName)
	local model = game.ReplicatedStorage.Characters:FindFirstChild(modelName)
	local oldModel = plr.Character
	local newModel = model:Clone()
	newModel.Name = plr.Name
	local oldCFrame = oldModel:GetPrimaryPartCFrame()
	oldModel:Destroy()
	plr.Character = newModel
	newModel.Parent = workspace -- [1] this follows current character loading behavior
	newModel:SetPrimaryPartCFrame(oldCFrame)
	local newAnimate = script.Animate:Clone()
	newAnimate.Parent = model
end
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		if not chr:GetAttribute("Character") then
			respawnPlayer(plr,"RangeBoio")
			game.ReplicatedStorage.Events.Ragdoll:FireClient(plr,true)
		end
	end)
end)

any other way to do this?

So you’re trying respawn the player on the same spot they Ragdoll?
Edit : Oh my god, I will punch myself for not reading it twice

No respawnPlayer switches the player’s character to an already existing character which is being cloned into workspace.

Okay, I know how to fix this one

Do i need to place the animate script in the replicated storage character?
Edit: tried, didnt work

Change it to this one :

-- Put this script inside ServerScriptService since it handle, well the Server
local function respawnPlayer(plr, modelName)
	local model = game.ReplicatedStorage.Characters:FindFirstChild(modelName)
	local newModel = model:Clone()
	newModel.Name = plr.Name

	local oldModel = plr.Character
	local oldCFrame = oldModel:GetPrimaryPartCFrame()
	oldModel:Destroy()

	plr.Character = newModel
	plr.Character.Parent = workspace -- Since the player's character has been changed, you don't  need to type "newModel.Parent"
	plr.Character:SetPrimaryPartCFrame(oldCFrame)

	local newAnimate = script.Animate:Clone()
	newAnimate.Parent = plr.Character
end
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		if not chr:GetAttribute("Character") then
			respawnPlayer(plr,"RangeBoio")
			game.ReplicatedStorage.Events.Ragdoll:FireClient(plr,true)
		end
	end)
end)

Nothing changed, the character still has no animation. (The script is already in ServerScriptService)

I will try to fix it right now.

1 Like

Hmm, did the script have “Animate” in it? And oh well, here is the newly done script :

local function respawnPlayer(plr, modelName)
	local model = game.ReplicatedStorage.Characters:FindFirstChild(modelName)
	local newModel = model:Clone()
	newModel.Name = plr.Name

	local oldModel = plr.Character
	local oldCFrame = oldModel:GetPrimaryPartCFrame()
	oldModel:Destroy()

	plr.Character = newModel
	plr.Character.Parent = workspace -- Since the character has changed, you don't  need to type "newModel.Parent"
	plr.Character:SetPrimaryPartCFrame(oldCFrame)

	if plr.Character:FindFirstChild("Animate") == nil then
		local newAnimate = script.Animate:Clone()
		newAnimate.Parent = plr.Character
	end
end

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		if not chr:GetAttribute("Character") then
			respawnPlayer(plr,"RangeBoio")
			game.ReplicatedStorage.Events.Ragdoll:FireClient(plr,true)
		end
	end)
end)

Edit : the reason why the other one doesn’t work, it’s because it has 8 “Animate” inside of the player’s character. All of the animations are overriding the same animations

Sorry for being late, it still does not work. idk why. something is weird and idk what.
is there any solution? i really need this to work.

Is the script is inside ServerScriptService?

Yes it is, it is enabled and everything should be working, but it still doesnt replicate.
i tried setting the original animate’s parent to the new character but still, nothing.

Can you show me your script so I can fix the problem?

Isn’t loadAnimation deprecated? it is still used in the animate script. also here:


image

You don’t have the “Animate” inside of “Chr”.

OH. ima try again, im sorry. [30cssss]