I want to play an animation only when the player jumps and is touching a part. How would I do that.
P.S. I have not been able to find anything on the wiki.
I want to play an animation only when the player jumps and is touching a part. How would I do that.
P.S. I have not been able to find anything on the wiki.
There is a simple, approximate solution to this and there are plentifully more complicated ones.
Just to clarify:
(1) You write that you want the animation to play when the player jumps "and is touching a part" - I interpret this to mean "and is on the ground"; the animation should only trigger if the player is supported by something (i.e. not falling).
(2) You aren't wanting to play an animation when two events are triggered; you want the animation to play when a certain, single event (Humanoid.Jumping) fires under specific circumstances (or conditions). The event, which happens in one tiny discrete unit of time, must happen whilst the condition 'Is the player on the ground?' is 'Yes' (true).
The ROBLOX client developers have spent a lot of time tweaking the behaviour of Player characters and the Humanoid - you can benefit from this. The Humanoid.Jumping event will only fire when the player can make a valid jump, which happens to be when the character is on the ground (which is the condition you want).
So, simply put, play your animation when the Humanoid.Jumping event fires.
By touching a part I was talking about an obstacle such as a building or something. I should've specified.
Although, the question you supplied does supply me with some interesting experiments for later on.
If you look at the answer I gave (to my own question, haha) about using the position of ROBLOX Parts to test for collisions, you could use a similar technique to detect if there is an obstacle in front of the player, perhaps.
That might work.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
This is actually a very tricky question: How do you know if the player is touching a part? See this question for some ideas: https://scriptinghelpers.org/questions/13175/custom-characters-detecting-the-ground