Issues playing character animation when proximity prompt is activated

Hi!

I attempted at altering some scripts I found online to play an animation on the player’s character when a proximity prompt is activated but to no avail. I don’t have any experience in scripting so I’m a bit confused as to what the problem is!
Here is what I tried:

local Animation = script.AnimationOpen

local promptbrick = workspace.animtest.ProximityPrompt

promptbrick.Triggered:Connect(function(Player)

local Animation = Player.Character:WaitForChild("Humanoid"):LoadAnimation(10511590770)

Animation:Play()

end)

Thank you so much for your time :slight_smile:

3 Likes

https://developer.roblox.com/en-us/api-reference/function/Humanoid/LoadAnimation
Expects an animation object not an animation’s asset ID.
https://developer.roblox.com/en-us/api-reference/class/Animation

5 Likes
local Animation = script.AnimationOpen
local promptbrick = workspace.animtest.ProximityPrompt
local AnimationObject = script.Parent -- for example

promptbrick.Triggered:Connect(function(Player)
    local Humanoid = Player.Character:WaitForChild("Humanoid")
    Humanoid:LoadAnimation(AnimationObject)
    Animation:Play()
end)
3 Likes

The :LoadAnimation() function ONLY accepts animation instances and not their ids, create an animation instance with the id and load with it