-
What do I want to achieve?
I want to make the animations to be played after the player hit “E” in their keyboard, I already made the animations to be instances & used “Animator” script inside the player character’s humanoid with LoadAnimation() function. -
What solutions have I tried so far?
The first one, I only used the rbxasset animations (no intances) to load Animation with “Animator” instances to load them it gives error, I read several other topics on devforum & that’s where I try to use instances to load them, & gives me this errors: Play is not a valid member of Animation"ServerScriptService.GameModule.MovementModule.Animation.CombatIdle"
The second one, I use the old way of playing animations which using “Humanoid” itself to load a animations, yet the output telling the same as above.
local AniF = script:WaitForChild("Animation")
local CID = AniF.CombatIdle
local NID = AniF.NormalIdle
function MovementModule.CombatOn(x)
local CombatIdle = "rbxassetid://16501904726" -- The Assets itself
local NormalIdle = "rbxassetid://180435571" -- The Asssets itself
local char = x.Character or x.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid") or char:FindFirstChildWhichIsA("Humanoid") -- Just check to be sure if the player has humanoid
local hAnimator = hum:FindFirstChild("Animator")
local AnimateScript = char:FindFirstChild("Animate")
if not hAnimator then
local NewAnimator = Instance.new("Animator", hum)
end
local function ChangeAnimation(z) -- Change Animations Function
if AnimateScript then
for _, v in pairs (AnimateScript:GetChildren()) do
if v:IsA("StringValue") and v.Name == "idle" then
for _, y in pairs(v:GetChildren()) do
y.AnimationId = z
end
else return nil
end
end
end
end
-- Check if they are ready to combat
if x:FindFirstChild("Status").CombatMode.Value == false then
if AnimateScript then
hAnimator:LoadAnimation(CID) -- HERE PROBLEM
CID:Play()
ChangeAnimation(CombatIdle)
x.Status.CombatMode.Value = true
print("COMBAT READY")
end
elseif x:FindFirstChild("Status").CombatMode.Value == true then
hAnimator:LoadAnimation(NID) -- HERE PROBLEM
NID:Play()
ChangeAnimation(NormalIdle)
x.Status.CombatMode.Value = false
print("Relax")
end
end
Output:
Play is not a valid member of Animation"ServerScriptService.GameModule.MovementModule.Animation.CombatIdle"