Proximity Prompt Not Triggering Player Animation

  1. What do you want to achieve?
    I’d like the proximity prompt to trigger a player animation.

  2. What is the issue?
    The proximity prompt is not triggering the animation. I will include the scripts below :slight_smile: & the output! Let me know if you need any more information!

  3. What solutions have you tried so far?
    I’ve been searching on Reddit & DevForum but haven’t been able to find anything related to the specific issue. I’m also new to coding/scripting and have tried re-writing the code multiple times.

More Information:

Local Script w/in PlayerStarterScripts:

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

-- Create new "Animation" instance
local paintAnimation = Instance.new("Painting")
-- Set its "AnimationId" to the corresponding animation asset ID
paintAnimation.AnimationId = "rbxassetid://9896373997"

-- Load animation onto the animator
local kickAnimationTrack = animator:LoadAnimation(paintAnimation)

Screen Shot 2022-06-12 at 11.22.41 PM

Script w/in the part w/ the prox.prompt:

local ProxPromp = script.Parent.ProximityPrompt
	local Anim = script:WaitForChild("Painting") -- assuming that your animation is a child of the script

ProxPromp.Triggered:Connect(function (player)-- gets the player
	local hum = player.Character:WaitForChild("Humanoid") -- gets the player's humanoid
	local animator = hum:WaitForChild("Animator")
	local loadAnim = hum:LoadAnimation(Anim) -- loads animation

	loadAnim:Play() -- plays the animation
end)

Screen Shot 2022-06-12 at 11.22.30 PM

In Output it says this:

Thank you so very much for your help, it’s greatly appreciated :smiley:

you mean

local paintAnimation = instance.new("Animation")
paintAnimation.Name = "Painting"
--instance.new is creating something, painting is not a thing lol

you mean

local paintAnimation = instance.new("Animation")
paintAnimation.Name = "Painting"
--instance.Name is renaming something, painting is not a string lol

CRYING RN LOOO ty yes ur right

(i was still right

Thank you for helping me fix that mistake; however, the code still doesn’t work. Output is saying that LoadAnimation requires an Animation object — I’ve tried to connect it to Animator within the Humanoid previously but it couldn’t find it.

Thank you for helping me out :slight_smile: However, the code still doesn’t work. Output is saying that LoadAnimation requires an Animation object — I’ve tried to connect it to Animator within the Humanoid previously but it couldn’t find it.

I figured out what I was doing wrong! I’ll attach the youtube video that I found to be extremely helpful!

How to Create an Eat Animation | Roblox Studio

Bare in mind the class’s name is also case-sensitive, instance points to nil and Instance the instance base class.

1 Like