I’ve got this module script that runs when Prompts are began/ended i’ve got it to play an animation when prompt begins but i can’t seem to find a way to make the animation :Stop() when the prompt ends because the animation is outside the scope and says Unknown global so I’m not sure what the work around is,
Script:
local SS = game:GetService(“ServerScriptService”)
local anims = SS:WaitForChild(“LootingAnims”)
local ObjectActions = {}
function ObjectActions.promptHoldBeganActions(promptObject, player, looting)
if looting == true then
local lootinganim =
{
anims:WaitForChild(“Looting”),
}
local char = player.Character
local human = char:WaitForChild("Humanoid")
local lootingAnim = human:LoadAnimation(lootinganim[1])
lootingAnim:Play() -- Animation
end
end
function ObjectActions.promptHoldEndedActions(promptObject, player, looting)
print (“Ended”) – Stop Animation here
end
Hey there! I believe this will fix the issue you’ve been having!
local anims = SS:WaitForChild(“LootingAnims”)
local lootinganim
local ObjectActions = {}
function ObjectActions.promptHoldBeganActions(promptObject, player, looting)
if looting == true then
lootinganim = anims:WaitForChild(“Looting”),
local char = player.Character
local human = char:WaitForChild("Humanoid")
local lootingAnim = human:LoadAnimation(lootinganim[1])
lootingAnim:Play() -- Animation
end
end
function ObjectActions.promptHoldEndedActions(promptObject, player, looting)
print (“Ended”) – Stop Animation here
if lootingAnim ~= nil then
lootingAnim:Stop()
end
end
local anims = SS:WaitForChild(“LootingAnims”)
local lootinganim
local ObjectActions = {}
function ObjectActions.promptHoldBeganActions(promptObject, player, looting)
if looting == true then
lootinganim = anims:WaitForChild(“Looting”),
local char = player.Character
local human = char:WaitForChild("Humanoid")
lootingAnim = human:LoadAnimation(lootinganim[1])
lootingAnim:Play() -- Animation
end
end
function ObjectActions.promptHoldEndedActions(promptObject, player, looting)
print (“Ended”) – Stop Animation here
if lootingAnim ~= nil then
lootingAnim:Stop()
end
end