Okay so, i made a script like months ago and decided to use it… I tested it and reset just to test it and it says this:
LoadAnimation requires the Humanoid object (WhatDId_HeDo.Humanoid) to be a descendant of the game object
Anyone knows a fix?
Edit; Here is the script:
local plr = game.Players.LocalPlayer
local Dash_Normal = 20
local Dash_Timeout = 0.15
local Can_Dash = false
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local CoolingDown = false
function DashForward(root) --script function by; overflowed on the dev forums; since idk this lol
local i = Instance.new('BodyPosition')
i.MaxForce = Vector3.new(1000000,0,1000000)
i.P = 100000
i.D = 2000
i.Position = (root.CFrame*CFrame.new(0,0,-Dash_Normal)).Position
i.Parent = root
coroutine.wrap(function()
wait(.2)
i:Destroy()
end)()
end
uis.InputBegan:Connect(function(key, processed)
if key.KeyCode == Enum.KeyCode.Q and not processed then
if CoolingDown then return end
local RootPart = char:FindFirstChild("HumanoidRootPart")
local Animation = script.Animation
local AnimationTrack = char.Humanoid:LoadAnimation(Animation)
if not RootPart then return end
CoolingDown = true
AnimationTrack:Play()
wait(1)
DashForward(RootPart)
local Animation = script.Animation
local AnimationTrack = char.Humanoid:LoadAnimation(Animation)
AnimationTrack:Stop()
wait(3)
CoolingDown = false
end
end)
when the character resets, im pretty sure the script resets as well meaning all the variables in the script are reset. If this is the case ur script is in startercharacterscripts.
A problem could be that an object ur referencing is a object inside the character that hasn’t loaded yet or an object that was deleted when the character was deleted when u reset causing the script to error.
This is all i can come up with without seeing ur script.
Is there anyway to fix this? I have come up with that aswell, but im not sure so i just didnt say it… I came up with it while researching, ill show u three the code once roblox is up since even i cant open studio lol
If the script is in StarterPlayerScripts you gotta manually update the character and all it’s descendants since it gets destroyed on death.
Example:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
Player.CharacterAdded:Connect(function(Char) --When the player respawns, gives updated character
Character = Char --Updates Character
Humanoid = Character:WaitForChild("Humanoid") --Updates Humanoid
end)
If you don’t feel like doing that you can do as stated above and move the script to StarterCharacterScripts.
Sounds like you may have put your scripts in StarterPlayerScripts.
I am guessing you are loading animation each time you want and that is what is causing the error. Is it possible if you could share your script? I know that Roblox Studio is down but do you have a copy or can you remember what you typed?
I assume you’re using CharacterAdded. CharacterAdded is kind of strange as it fires before the character is actually parented to the game, and is actually parented to nil during this state. I assume the error stems from the fact that you immediately try to load the animation before the character can be parented to the workspace. There are a couple methods I’ve found to circumvent this, but this usually works for me:
local Player = Player -- Set the player here.
Player.CharacterAdded:Connect(Character)
Character.AncestryChanged:Wait() -- Wait for the character to change parents (usually means its parented to workspace/game).
local Humanoid = Character:WaitForChild("Humanoid") -- Get the Humanoid.
local Loaded = Humanoid:LoadAnimation(Animation) -- Load the animation.
end)
There have been other posts about this before, so make sure you also always search up about something before posting onto here, and you can read those posts below:
local plr = game.Players.LocalPlayer
local Dash_Normal = 20
local Dash_Timeout = 0.15
local Can_Dash = false
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local CoolingDown = false
function DashForward(root) --script function by; overflowed on dev forums; since idk this lol
local i = Instance.new('BodyPosition')
i.MaxForce = Vector3.new(1000000,0,1000000)
i.P = 100000
i.D = 2000
i.Position = (root.CFrame*CFrame.new(0,0,-Dash_Normal)).Position
i.Parent = root
coroutine.wrap(function()
wait(.2)
i:Destroy()
end)()
end
uis.InputBegan:Connect(function(key, processed)
if key.KeyCode == Enum.KeyCode.Q and not processed then
if CoolingDown then return end
local RootPart = char:FindFirstChild("HumanoidRootPart")
local Animation = script.Animation
local AnimationTrack = char.Humanoid:LoadAnimation(Animation)
if not RootPart then return end
CoolingDown = true
AnimationTrack:Play()
wait(1)
DashForward(RootPart)
local Animation = script.Animation
local AnimationTrack = char.Humanoid:LoadAnimation(Animation)
AnimationTrack:Stop()
wait(3)
CoolingDown = false
end
end)
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer or plrs.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local Dash_Normal = 20
local Dash_Timeout = 0.15
local Can_Dash = false
local CoolingDown = false
function DashForward(root) --script function by; overflowed on dev forums; since idk this lol
local i = Instance.new('BodyPosition')
i.MaxForce = Vector3.new(1000000,0,1000000)
i.P = 100000
i.D = 2000
i.Position = (root.CFrame*CFrame.new(0,0,-Dash_Normal)).Position
i.Parent = root
coroutine.wrap(function()
wait(.2)
i:Destroy()
end)()
end
uis.InputBegan:Connect(function(key, processed)
if key.KeyCode == Enum.KeyCode.Q and not processed then
if CoolingDown then return end
local RootPart = char:WaitForChild("HumanoidRootPart")
local Animation = script.Animation
local AnimationTrack = char.Humanoid:LoadAnimation(Animation)
if not RootPart then return end
CoolingDown = true
AnimationTrack:Play()
wait(1)
DashForward(RootPart)
local Animation = script.Animation
local AnimationTrack = char.Humanoid:LoadAnimation(Animation)
AnimationTrack:Stop()
wait(3)
CoolingDown = false
end
end)
This would be better since it waits for the player’s character to load correctly and then the HMR to load before attempting to perform the animation. Your original script likely would’ve worked if placed in the StarterCharacterScripts folder though.