Stop is not a valid member of Animation

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

    I want to animation stop and destroy when proximity prompt triggered

  2. What is the issue? Include screenshots / videos if possible

    it gives me an error:

Stop is not a valid member of Animation "StarterPlayer.StarterPlayerScripts.TakePizza.Animation"
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

    I tried to create animation from instance but animation won’t stop playing nor destroying

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
this is my script:

local hrp = script.Parent
local event = game.ReplicatedStorage.Remotes:WaitForChild("GiveCharPizzaEvent")

hrp.ProximityPrompt.Triggered:Connect(function(player)
	local char = player.Character or player.CharacterAdded
	local hum = char:WaitForChild("Humanoid")
	player.leaderstats.Money.Value = player.leaderstats.Money.Value + 15
	event:FireClient(player)
	print(event)
	wait(0.5)
	hrp.Parent:Destroy()
	local animation = game.StarterPlayer.StarterPlayerScripts.TakePizza.Animation
	animation:Stop()

end)

I t will be great help if anyone could help me solve this :slight_smile: :slight_smile:
thank you

3 Likes

Animation, which is the instance you are referring to in the script, does not have such function, but AnimationTrack does. You have to properly load the animation to the Animator and then use the stop function on the AnimationTrack.

2 Likes

Thx works perfectly fine now :slight_smile: :slight_smile:

Why not mark her reply as a solution

ooops…forgot lol :sweat_smile::sweat_smile:

1 Like