Basically I am making a tool with animations, but I am having trouble loading the animations, getting the humanoid etc.
local blade = script.Parent.BladeGlow1
local LightSaber = script.Parent
script.Parent.Equipped:Connect(function()
local Character = LightSaber.Parent
local humanoid = Character.Humanoid -- Works here perfectly fine
local Idle = humanoid:LoadAnimation(script:WaitForChild('Idle'))
local EquipAnim = humanoid:LoadAnimation(script:WaitForChild('Equip'))
EquipAnim.Priority = Enum.AnimationPriority.Movement
EquipAnim:Play()
wait(1)
Idle.Looped = true
Idle.Priority = Enum.AnimationPriority.Movement
Idle:Play()
end)
script.Parent.Unequipped:Connect(function()
local Character = LightSaber.Parent
local humanoid = Character.Humanoid -- doesn't work here for some reason????
local Idle = humanoid:LoadAnimation(script:WaitForChild('Idle'))
Idle.Looped = false
end)
For some reason the humanoid variable only works when I put it in the equipped function.
Doesn’t work in thee unequipped function or outside of the functions.
Humanoid is not a valid member of Backpack “Players.Rvzol.Backpack”
When the gear is unequipped, its parent is replaced to the backpack of the player, so its not possible to initialize the Character from .Parent since its new parent is .Backpack
local blade = script.Parent.BladeGlow1
local LightSaber = script.Parent
local Character
script.Parent.Equipped:Connect(function()
Character = LightSaber.Parent
local humanoid = Character.Humanoid -- Works here perfectly fine
local Idle = humanoid:LoadAnimation(script:WaitForChild('Idle'))
local EquipAnim = humanoid:LoadAnimation(script:WaitForChild('Equip'))
EquipAnim.Priority = Enum.AnimationPriority.Movement
EquipAnim:Play()
wait(1)
Idle.Looped = true
Idle.Priority = Enum.AnimationPriority.Movement
Idle:Play()
end)
script.Parent.Unequipped:Connect(function()
local humanoid = Character.Humanoid -- doesn't work here for some reason????
local Idle = humanoid:LoadAnimation(script:WaitForChild('Idle'))
Idle.Looped = false
end)
This should work.
I hope this help you and if you have questions please reply