This animation does not play when clicked, but “I was clicked” is still in the output.
local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Sword = script.Parent
Sword.Activated:Connect(function()
print("I was clicked")
local Animation = Sword.SwordAnimation
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end)
Im assuming the sword is a tool so i could set the character to the sword parent
also use math.huge probably because of loading issues
local Sword = script.Parent
local Character = Sword.Parent
local Humanoid = Character:WaitForChild("Humanoid", math.huge)
local Animation = Sword:WaitForChild("SwordAnimation", math.huge)
local AnimationTrack = Humanoid:LoadAnimation(Animation)
Sword.Activated:Connect(function()
print("I was clicked")
AnimationTrack:Play()
end)
Player = game.Players.LocalPlayer
local TorsoRot = Instance.new("Animation")
TorsoRot.AnimationId = "rbxassetid://11641202131"
local PlayTorsoRot = Player.Character.Humanoid:LoadAnimation(TorsoRot)
Instead of
local Humanoid = Character:WaitForChild("Humanoid", math.huge)
local Animation = Sword:WaitForChild("SwordAnimation", math.huge)
local AnimationTrack = Humanoid:LoadAnimation(Animation)
-- Variables
local Player = game.Players.LocalPlayer
local Sword = script.Parent
local Character = Sword.Parent
-- Manually Create The Animation
local SwordAnim = Instance.new("Animation")
SwordAnim .AnimationId = "rbxassetid://youridhere"
local PlaySword = Player.Character.Humanoid:LoadAnimation(SwordAnim)
-- OnActivated
local function onActivated()
print("I was clicked")
local AnimationTrack = Humanoid:LoadAnimation(Animation)
PlaySword:Play()
end
Sword.Activated:Connect(onActivated)
Ok, I edited your code a bit to fix some errors, and it actually does play the animation, however the holding animation for every item seems to overwrite it. Would there be a way to overwrite that animation?
local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local Sword = script.Parent
Sword.Activated:Connect(function()
print(“I was clicked”)
local Animation = Sword.SwordAnimation
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end)
]]
local LocalPlayer = game:GetService(“Players”).LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)
local Sword = script.Parent
local function OnClicked()
print(“I was clicked”)
local Animation = Sword.SwordAnimation
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end