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

Idle Animation Doesn't Stop On Unequip Gun?

Asked by 4 years ago

It doesn't stop I dont have a script I want a script to stop it there is a screen shot of my Animations and scripts: https://gyazo.com/ecc0c2781fa337608775d7933642f7be

I need to fix this script below [Dont add the code block lines.]

~~~~~~~~~~~~~~~~~

-- Waits for the child of the specified parent local function WaitForChild(parent, childName) while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end

local Tool = script.Parent

local Animations = {} local MyHumanoid local MyCharacter

local function PlayAnimation(animationName) if Animations[animationName] then Animations[animationName]:Play() end end

local function StopAnimation(animationName) if Animations[animationName] then Animations[animationName]:Stop() end end

function OnEquipped(mouse) MyCharacter = Tool.Parent MyHumanoid = WaitForChild(MyCharacter, 'Humanoid') if MyHumanoid then Animations['EquipAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'EquipAnim5')) end PlayAnimation('EquipAnim') end

function OnUnequipped() for animName, _ in pairs(Animations) do StopAnimation(animName) end end

Tool.Equipped:connect(OnEquipped) Tool.Unequipped:connect(OnUnequipped)

WaitForChild(Tool, 'PlaySlash').Changed:connect( function (value) --if value then PlayAnimation('SlashAnim') --else -- StopAnimation('SlashAnim') --end end)

WaitForChild(Tool, 'PlayThrust').Changed:connect( function (value) --if value then PlayAnimation('ThrustAnim') --else -- StopAnimation('ThrustAnim') --end end)

WaitForChild(Tool, 'PlayOverhead').Changed:connect( function (value) --if value then PlayAnimation('OverheadAnim') --else -- StopAnimation('OverheadAnim') --end end)

~~~~~~~~~~~~~~~~~

0
Use block code, man Psudar 882 — 4y
0
Psudar Very true its making me confused. Luka_Gaming07 534 — 4y
0
Go down to answers and see the block code MarkusIsCoolForever -2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
-- Waits for the child of the specified parent local function WaitForChild(parent, childName) while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end

local Tool = script.Parent

local Animations = {} local MyHumanoid local MyCharacter

local function PlayAnimation(animationName) if Animations[animationName] then Animations[animationName]:Play() end end



local function StopAnimation(animationName) if Animations[animationName] then Animations[animationName]:Stop() end end

function OnEquipped(mouse) MyCharacter = Tool.Parent MyHumanoid = WaitForChild(MyCharacter, 'Humanoid') if MyHumanoid then Animations['EquipAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'EquipAnim5')) end PlayAnimation('EquipAnim') end

function OnUnequipped() for animName, _ in pairs(Animations) do StopAnimation(animName) end end



Tool.Equipped:connect(OnEquipped) Tool.Unequipped:connect(OnUnequipped)

WaitForChild(Tool, 'PlaySlash').Changed:connect( function (value) --if value then PlayAnimation('SlashAnim') --else -- StopAnimation('SlashAnim') --end end)

WaitForChild(Tool, 'PlayThrust').Changed:connect( function (value) --if value then PlayAnimation('ThrustAnim') --else -- StopAnimation('ThrustAnim') --end end)

WaitForChild(Tool, 'PlayOverhead').Changed:connect( function (value) --if value then PlayAnimation('OverheadAnim') --else -- StopAnimation('OverheadAnim') --end end)
Ad

Answer this question