Hey there!
I’m scripting a combat system for a game I am a developer for but I am having some problems with the tools animation, it doesn’t use the idle that is already saved “Idle_Animation”.
Here’s the code
tool.Equipped:Connect(function()
if canIdle then
canIdle = true
end
local str = Instance.new("StringValue")
str.Name = "Idle_Animation"
str.Value = "Idle_Animation"
str.Parent = tool
canIdle = true
Sounds.Unsheath:Play()
end)
I think it is working it’s just not staying the whole time.
If you need to see more just let me know and I can show you.
Load the animation, set it to loop, then re-export it.
Inside of the script, define the Animation instance and put a line of script on it’s own saying [AnimationInstance].Looped = true.
You don’t have to use a StringValue to change the animation’s name. You can change it directly within your script or change the name of it in it’s properties.
You can still loop the animation by defining the Animation Instance and doing .Looped = true. Also, you’ve actually answered your question there. You cannot see animations if they weren’t made by you and wasn’t uploaded in a group that you both share.
Okay I’ve taken some time to fix the code, though it still isn’t playing the animations, I think my mistakes are just silly mistakes that I’ve missed.
local tool = script.Parent
local canDamage = false
local canSwing = true
local canIdle = true
local Attack1_Animation = tool.Animations.Attack1_Animation
local Idle_Animation = tool.Animations.Idle_Animation
local Handle = script.Parent:WaitForChild(("Handle"))
local AttackTrail = tool.Handle.AttackTrail
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local Sword_Walk_Animation = Instance.new("Animation")
Sword_Walk_Animation.AnimationId = "rbxassetid://9404399317"
local Sword_Walk_AnimationTrack = Animator:LoadAnimation(Sword_Walk_Animation)
Sword_Walk_AnimationTrack.Priority = Enum.AnimationPriority.Movement
Sword_Walk_AnimationTrack.Looped = true
local Sword_Slash_Animation = Instance.new("Animation")
Sword_Slash_Animation.AnimationId = "rbxassetid://9404404634"
local Sword_Slash_AnimationTrack = Animator:LoadAnimation(Sword_Walk_Animation)
Sword_Slash_Animation.Priority = Enum.AnimationPriority.Action
Sword_Slash_Animation.Looped = false
DamageValues = {
Attack1 = 5,
Attack2 = 10,
Attack3 = 30
}
Effects = {
BloodEmitter = Handle:WaitForChild("BloodEmitter"),
}
Sounds = {
Slash = Handle:WaitForChild("SlashSound"),
Lunge = Handle:WaitForChild("LungeSound"),
Unsheath = Handle:WaitForChild("EquipSound"),
HitSound1 = Handle:WaitForChild("HitSound1")
}
tool.Equipped:Connect(function(player)
Sword_Walk_AnimationTrack:Play()
Sounds.Unsheath:Play()
end)
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(5)
Sounds.HitSound1:Play()
else
return
end
canDamage = false
end
local function slash()
if canSwing then
canSwing = false
Sword_Slash_AnimationTrack:Play()
canDamage = true
wait(1)
canSwing = true
Sword_Slash_AnimationTrack:Play()
end
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
^ This is the full code but just pick out the parts where it uses :Play()
That’s the reason it’s not loading. Nothing is wrong with your script, you’ll need the owner to test the game out for you to see if the animations work.
Unless the game has been published in a group that you both share and the animations has been under that group as well, the animations won’t show for the person who wasn’t the one uploading the animation.