Dash script not working after dying?

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)

Can you show me the whole script? It is really hard to debug without the script

2 Likes

Provide the script so that you can be assisted.

1 Like

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.

1 Like

Roblox is currently down right now, even roblox studio cant be opened sadly… Ill tell u the code later after its open again!

as i said:

Ill make sure to tell you and @AGamerplays12 the code when its open!!

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

Wait, what is the character reload time you set?

1 Like

What do you mean? Can you elaborate i dont understand sorry

My bad, I think I worded it not correctly.

What is the respawn time you set in the Players service?

@WhatDid_HeDo If you just place the script in StarterCharacterScripts then it should work after you respawn.

(Make sure to change variables that may be intended for specific things like player/character)

1 Like

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.

3 Likes

I didnt do anything to the respawn time on players, i didnt even know it existed

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?

1 Like

Unfortunately not, i dont remember it nor do i have a copy… i have a studio save but its not working either

1 Like

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:

Getting Error "LoadAnimation requires the humanoid object to be a descendant of the game object despite waiting for character

I hope this helps!

2 Likes

@AGamerplays12
@EyesInDisguise1
@Limited_Unique
Here is the script since roblox is back up!!

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)

just change the char variable for this

local char = script.Parent

and move the script to StarterCharacterScripts

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

1 Like