Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What exactly am i doing wrong in this animation script? *REPOSTED AND UNSOLVED*

Asked by
Sorukan 240 Moderation Voter
5 years ago

The animation isn't suppose to work anymore when i unequipped the tool and i have no idea what i'm doing wrong, the output doesn't print any error either so i don't understand.

--//Services
local UIS = game:GetService('UserInputService')

--//Variables
local tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character

--//Use this since it's a local script inside a tool
player.CharacterAdded:Connect(function(character)
char = character
local hum = char:WaitForChild('Humanoid')

--//Animation
local spinSlash = hum:LoadAnimation(tool.SpinSlash)

--//Equipped
tool.Equipped:Connect(function()

--//Input
local debounce = false
UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.X and not debounce then
        debounce = true
        spinSlash:Play()
        wait(2)
        debounce = false
    end
    end)
end)

--//Unequipped
tool.Unequipped:Connect(function()
    spinSlash:Stop()
    end)
end)

I'm trying to make it so that pressing the X button would only play the animation if my tool was equipped.

0
Why are your events nested in the Equipped event? That is almost what you DON'T want. User#24403 69 — 5y
0
You never got the ID of the animation greatneil80 2647 — 5y
0
I want to make it so that the animation plays only when i'm equipping my tool, how else am i suppose to do that if they're not nested in the equipped event? Sorukan 240 — 5y
0
Yeah wheres the id of the animation? TheOnlySmarts 233 — 5y
View all comments (2 more)
0
Also i put the animation inside the tool along with the ID so i don't need to write it in the script Sorukan 240 — 5y
0
The animation works but it's just that i want it to only work while i'm equipping the tool Sorukan 240 — 5y

Answer this question