Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to change character and keep animations running?

Ok so I have a idea to make a game where you sorta go around an possess different characters. Ive made a map with a ton of noob npcs that you can possess and control Heres the script. BTW it is a local script but I have filtering enabled off. So you press q to switch but when you switch it works but when you move around it doesnt run the animations such as walking and jumping. If you want to try the place this is the link:https://web.roblox.com/games/672192244/Switch And here's the script:

-- Switch script by Wafflecow321
-- in dev
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera

function Click(input,gp)
if input.UserInputType == Enum.UserInputType.Keyboard then
	if input.KeyCode == Enum.KeyCode.Q then
	if Mouse.Target then
		if Mouse.Target.Parent:FindFirstChild("Humanoid")and not Mouse.Target:IsDescendantOf(Player.Character)then
		Player.Character.Archivable = true
		if Player.Character:FindFirstChildOfClass("Tool")then
			Player.Character:FindFirstChildOfClass("Tool"):Destroy()
		end
		local Char = Player.Character
		local Clone = Char:Clone() 
        Clone.Parent = workspace
        print(Mouse.Target.Parent.Name) 
        local Target = Mouse.Target
		Camera.CameraSubject = Target.Parent
		Player.Character = Target.Parent
		end
	end
	end
	end
end
UIS.InputBegan:connect(Click)

I don't rlly care if you copy this but plzz be considerate and give me credit.

1 answer

✓ Accepted answer

I'm pretty sure if you disable the Animate script inside the character, then re-enable it, the animations should recalibrate.

local Char = Player.Character
local Clone = Char:Clone() 
Clone.Parent = workspace
local Target = Mouse.Target
Camera.CameraSubject = Target.Parent
Player.Character = Target.Parent

wait(1)

local anim = Player.Character:WaitForChild("Animate");
anim.Disabled = true;
anim.Disabled = false;

Test around with this idea.

1 comment

0

Thanks that fixed everyting

This discussion is preserved as it was. New answers, comments, and votes are closed.