generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: ROBLOX Stopping an animation?

Previous Thread :: Next Thread 
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 10:56 AM
Hey, I've followed the wiki about playing an animation on an NPC but now I'm a bit stuck... I don't know how to stop the animation the way I want it to stop?

So basically I have this in a touch-event.

local animation = hit.Parent.LehAnimation
local animController = hit.Parent.LehAnimationController
_G.animTrack = animController:LoadAnimation(animation)
hit.Parent.Torso.Anchored = true
_G.animTrack:Play()

So as you can see there, I'm currently using a global variable but I don't want to use global variables because I want this to work with a lot of animTracks of the same kind. You can also see that there's a Animation and a AnimationController located inside the NPC.

Now, I have it so the the NPC can pathfind by the player so if the player were to use Pathfinding on the NPC, I would like to stop the animation.

I've done:

if _G.animTrack ~= nil then
_G.animTrack:Stop()
_G.animTrack = nil
end

Inside the pathfind and this works okay but as I said I want to run multiple animations (Could be over 200 or so in the future >.<)

Has anyone got any ideas? Thanks.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 10:59 AM
Also, for some reason I can't move the torso of the NPC or rotate it, when I'm working on animation? Why is this and is there a solution?

Thanks again.
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
09 Apr 2015 11:00 AM
em, y _G?

Here's my siggy... Done.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 11:01 AM
The pathfinding script is located inside a different script, that's why I can't access "animTrack", so I had to use a global variable in order to access it. I'm trying not to use a _G variable though.
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
09 Apr 2015 11:04 AM
hmmm... well I dunno wat the Hierarchy looks like in ur Game, and if u did tell it would take some time to check everything and stuff :/
if it was my Game I could Fix it in a few Secs prob XD
sry, I can't help :\

Here's my siggy... Done.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 11:09 AM
I think I've found a solution... I've got it so if you leave the area then a TouchEnded stops the animation without having to go in another script ;o ;3 Hopefully TouchEnded doesn't glitch out tho xD

I've got another problem on my hands though... I can't move the character's torso and I can't rotate it either ;S I think this is because the HumanoidRootPart is the same size as the Torso so I'm locking in on the HumanoidRootPart instead of the torso ;/ Is there a way to make the Torso appear in front of the HumanoidRootPart so I can edit it or no? I can't move the HumanoidRootPart or my NPC disappears when I start the game xD
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
09 Apr 2015 11:20 AM
em all u could do rlly is change the 'Root Hip' C1 :/

Here's my siggy... Done.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 11:30 AM
Ah okay, thanks! :D Done. I might have to bump this later because I'm not sure if the TouchEnded will work so well but for now everything's good, thanks ;3
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 11:35 AM
O, It seems that I have to have the motor6D already in there while animating or when I use the HumanoidRootPart, nothing is connected to it so I can't animate with it, I can use the Torso but then I have the same problem as before as I can't move the main part or HumanoidRootPart still with it ;S
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 12:08 PM
bump
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 12:47 PM
Oh god and the animation isn't viable too, it works for one NPC but if another NPC touches it then It doesn't work because the first animTrack gets overridden by the second one so the first npc never stops the animation D:
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
09 Apr 2015 01:41 PM
np...
and em... well, wats exactly the Problem?
I can't understand...

Here's my siggy... Done.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 03:40 PM
Ah, well basically I have a Part you can touch and when the npc touches the Part, the npc plays an animation. If NPC1 were to touch the part, it would set this up:

local animation = hit.Parent.LehAnimation
local animController = hit.Parent.LehController
animTrack = animController:LoadAnimation(animation)

and then play the animation with animTrack:Play()

The problem with this though is that if the second NPC were to touch the Part, it would over-ride the animTrack so the TouchEnded event I have where it stops the animation with :Stop() wouldn't stop the first NPC

These animations loop btw ^^
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 03:52 PM
Ah, well basically I have a Part you can touch and when the npc touches the Part, the npc plays an animation. If NPC1 were to touch the part, it would set this up:

local animation = hit.Parent.LehAnimation
local animController = hit.Parent.LehController
animTrack = animController:LoadAnimation(animation)

and then play the animation with animTrack:Play()

The problem with this though is that if the second NPC were to touch the Part, it would over-ride the animTrack so the TouchEnded event I have where it stops the animation with :Stop() wouldn't stop the first NPC

These animations loop btw ^^
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
09 Apr 2015 04:40 PM
oh
i dunno, might be cos Roblox "might" not record TouchEnded if it wasnt't the Part that moved, but something moved it...
try maybe changing, from the Part.TouchEnded to NPC's BodyPart.TouchEnded and check if it's the same Part that u want to make the Effect...
if u get me
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 06:43 PM
I don't think that'll work either because I can't transfer animTrack = animController:LoadAnimation(animation) anywhere;/ Sure I could transfer that to the NPC but the .Touched might be different than the .TouchEnded Part if you know what I mean.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 06:58 PM
I don't think we was talking about the same thing actually nvm but basically I don't think I can use a TouchEnded because if one NPC were to touch a part it would animTrack:Play() and then if another one touches the part it would also animTrack:Play() but it would over-ride the first NPC that touched it so animTrack would belong to the second NPC and not the first so if the first one were to TouchEnded the part, the animation would still continue.
Report Abuse
ColdUndermined is not online. ColdUndermined
Joined: 25 Jan 2010
Total Posts: 1819
09 Apr 2015 07:24 PM
Okay, there's 3 very important steps you need to follow to make this work:

1) lOOK at your post.
2) lOOK at the sp00ky "the the".
3) Use grammar correctly.
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
09 Apr 2015 07:31 PM
ehh? You can clearly see that's a typo... ;/
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
10 Apr 2015 07:43 AM
lol I didn't know wat I said XD
so...
u could've used Debounce, which could Record wen 1 Dude Touches it, then Debounce is true so wen some other dude Touches it it doesn't Record it...
well ya get wat I mean XD
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 07:53 AM
I got 2 steps for you king.

1. Put this in another thread, it's not longer "How to stop an animation"
2. Use a freaking ModuleScript, _G sucks.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image