Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to change character and keep animations running?

Asked by 7 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 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 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 457 — 7y
Ad

Answer this question