Proximity Prompt Ended animation stop?

Hi there,

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

return ObjectActions

Thanks,

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

Tried that and it returned the same issue? “Unknown global”?

Can you send a screenshot of the output?

ServerScriptService.ObjectActions:19: attempt to index nil with ‘Stop’

Try this and tell me if it works!

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
1 Like

Worked!, with some small minor typo changes! Thanks alot man,

1 Like