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.
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.
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
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