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

How can I disable the default "Animate" script in a spawned character?

Asked by 5 years ago

I am trying to disable the default "Animate" script that automatically spawns in characters so that I can make my own custom controls & animations for a custom character. Neither of the two strategies I tried worked. Am I just missing some information about network ownership or replication? I thought this could be done on a local script.

BOTH LOCAL SCRIPTS 1.

player = game.Players.LocalPlayer
player.CharacterAdded:Connect(function(character)
    character:WaitForChild("Animate").Disabled = true
end)

DOES NOT WORK.

2.

player = game.Players.LocalPlayer
oldAnimate = game.workspace:WaitForChild(player.Character.Animate)
oldAnimate.Disabled = true

DOES NOT WORK

With both ways (local scripts), the "Animate" script "Disabled" box is still unchecked when I look in the character model in the workspace when the game is launched.

0
If my script works for you, then can you mark it as the correct answer? SteamG00B 1633 — 5y

3 answers

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

For fix this use ServerScripts!

For first, insert a ServerScript(Script) in ServerScriptService and put this script:

game.Players.PlayerAdded:Connect(function(plr) -- On player added get player
    plr.CharacterAdded:Connect(function(char) -- On character of player added get character
        local anims = char:WaitForChild("Animate") -- Wait for script named as "Animate"
        anims.Disabled = true -- Disable the Animate script.

        -- Go to stop all anims in Humanoid
        for _,Anim in pairs(char:WaitForChild("Humanoid"):GetPlayingAnimationTracks()) do -- Wait for humanoid and get all anim's in humanoid, after get humanoid and tracks stop all
            Anim:Stop() -- Stop all anims.
        end
    end)
end)

Players.PlayerAdded - Detect if a player added in game (Only ServerScript)

Player.CharacterAdded - Detect character of player added

WaitForChild - Wait for instance

For loop - Loop to get all in a "table", and you can use this for re-name items... and more.

GetChildren - Transform children of location in a "table"

Examples:

-- WaitForChild
workspace:WaitForChild("Item").Parent = game.ServerStorage -- Wait for item and put it on ServerStorage

-- PlayerAdded
game.Players.PlayerAdded:Connect(function(player)
    print("The player " .. player.Name .. " joined to game!")
end)

-- CharacterAdded
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        print("The char of player " .. player.Name .. " spawned!")
    end)
end)

-- generic for loop
for index,value in pairs(workspace:GetChildren()) do -- Get all in workspace in a "table"
    print(value.Name) -- Print name of all items in workspace
end

Hope it helped, Errors? tell-me on comments.

Wiki pages

For loop

WaitForChild

GetChildren

PlayerAdded

CharacterAdded


Solved your problems? put [SOLVED] in title or accept a answer.
Ad
Log in to vote
0
Answered by 5 years ago

The local script wouldn't work for the character, so heres my try which isnt in a local.

game.Players.PlayerAdded:Connect(function(plr)
plr:WaitForChild("Character")
plr.Character.CharacterAdded:Connect(function(character)
character.Animate.Disabled = true
0
is the character not replicated because it is part of the workspace or is it a special property of Player.Character to *not* be accessible by local scripts? Phibonacci 37 — 5y
0
Well, tbh i think it can be accessed by local scripts, but this one might work better. Tell me if the entire thing works. User#22722 20 — 5y
0
SMH it's because changes to character scripts on the client-side aren't replicated to the server Zenith_Lord 93 — 5y
Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
5 years ago
Edited 5 years ago

If you don't care about not getting the default animations back, then you could have a script that actually replaces them with the ones you want, so you don't have to add a new script to run your animations.

But if you don't want to do that, then you can just have this in character scripts:

wait()
script.Parent.Animate.Disabled = true
0
i tried that code in both a local script and a server-script, both inside the character model, and the "Animate" "Disabled" box is still unchecked Phibonacci 37 — 5y

Answer this question