Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How to change character and keep animations running?

Asked by 2 years ago

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

Log in to vote
0
Answered by
Goulstem 8028 Badge of Merit Moderation Voter Administrator Community Moderator
2 years ago
Edited 2 years ago

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.

0
Thanks that fixed everyting Wafflecow321 361 — 2y
Ad

Answer this question