You can write your topic however you want, but you need to answer these questions:
So I’ve been trying to make a Chopping animation Play when the player Equips a tool, and Clicks anywhere on the screen. I Haven’t been able to fix it yet so any help would be helpful!
It’s pretty hard for me, I’m not the best scripte, but I’ve tried my best but couldnt get it working.
local tool = script.Parent
local equippedtool = false
local animTrack = nil
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local character = player.Character or player.CharacterAdded:Wait()
end)
end)
local Axe1 = game.ReplicatedStorage.Axe1
local Axe2 = game.ReplicatedStorage.Axe2
local can1 = true
local can2 = false
local anim1 = Instance.new("Animation")
anim1.AnimationId = "http://www.roblox.com/Asset?ID=7201386019"
local anim2 = Instance.new("Animation")
anim2.AnimationId = "http://www.roblox.com/Asset?ID=7201633002"
local canplay1 = true
local canplay2 = false
tool.Activated:Connect(function()
if can1 == true and can2 == false then
Axe1:FireServer()
print("AxeAnimation1 Fired")
elseif can1 == false and can2 == true then
Axe2:FireServer()
print("AxeAnimation2 Fired")
end
end)
Axe1.OnServerEvent:Connect(function()
print("Axe 1 Clicked")
canplay1 = false
canplay2 = true
animTrack = character.Humanoid:LoadAnimation(anim1)
animTrack:Play()
end)
Axe2.OnServerEvent:Connect(function()
print("Axe 2 Clicked")
canplay2 = false
canplay1 = true
animTrack = character.Humanoid:LoadAnimation(anim2)
animTrack:Play()
end)
Only help, if you have time, I don’t wnana waste anyones time!
You don’t have to play the animation from the server, You could just do this.
local tool = script.Parent
local animTrack = nil
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local anim1 = Instance.new("Animation")
anim1.AnimationId = "http://www.roblox.com/Asset?ID=7201386019"
anim1.Parent = tool
local anim2 = Instance.new("Animation")
anim2.AnimationId = "http://www.roblox.com/Asset?ID=7201633002"
anim2.Parent = tool
local track = 1
tool.Activated:Connect(function()
if track == 1 then
animTrack = character.Humanoid:LoadAnimation(anim1)
animTrack:Play()
track += 1
else
animTrack = character.Humanoid:LoadAnimation(anim2)
animTrack:Play()
track = 1
end
end)