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

How do you make swapped Player.Characters have animations?

Asked by 4 years ago

I have a script that switches two players characters.

ex:

game.Players.Player1.Character = workspace.Player2
game.Players.Player2.Character = workspace.Player1

Now yes this code wouldn't actually work i'd have to add buffers and cloning and etc but in the end, i have a script that does this. Thing is, after swapping the characters, animations no longer works. Part of the script has to do with cloning the player and such. What would cause a player not to have animations? Heres my swapping script: (the two values have the names of what players are on them.)

while wait(.01) do
    if script.Parent.swap1.player1.Value ~= "" and script.Parent.swap2.player2.Value ~= "" then
        local initialname1 = script.Parent.swap1.player1.Value
        local initialname2 = script.Parent.swap2.player2.Value
        local whomst1 = game.Players[script.Parent.swap1.player1.Value]
        local whomst2 = game.Players[script.Parent.swap2.player2.Value]
        local character1 = whomst1.Character
        local character2 = whomst2.Character
        local clone1 = character1:Clone()
        local clone2 = character2:Clone()
        local clone3 = character1:Clone()
        local clone4 = character2:Clone()
        clone3.Parent = workspace
        clone4.Parent = workspace
        clone1.Parent = workspace
        clone1.Name = clone1.Name.."_Swap"
        clone2.Parent = workspace
        clone2.Name = clone2.Name.."_Swap"
        whomst1.Character = clone2
        whomst2.Character = clone1
        script.Parent.swap1.player1.Value = ""
        script.Parent.swap2.player2.Value = ""
        whomst1.Character = clone4
        whomst2.Character = clone3
        clone3.HumanoidRootPart.Anchored = false
        clone4.HumanoidRootPart.Anchored = false
        game.ReplicatedStorage.SwapCameras:FireClient(whomst1, clone4.Name)
        game.ReplicatedStorage.SwapCameras:FireClient(whomst2, clone3.Name)

    end
end

Also, note: the SwapCameras swap the cameras. (duh)

Answer this question