Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a script for an avatar to eat a food and pick it up? (goes in inventory).

Asked by 4 years ago

I'd like to make a script for Cafe food example: A cookie, how do I make it where the avatar picks it up (in the inventory) and then eat's it? Please help, thank you :)

0
do you have any scripts for us to modify? lytew 99 — 4y

1 answer

Log in to vote
0
Answered by
JPT79 92
4 years ago

Well first off make your food model, if it has multiple parts either weld them together or make them into a union, then rename the part to Handle and place it in a tool, now when a player touches the food it will go in their inventory. Mess around with the gripPos until the player holds the food correctly, then your tool is ready. As for scripting I won't write out a whole script for you as that's not what this website is for, but I will point you in the direction of what you need to do. You'll want to put a local script inside your tool (and a sound effect if you'd like) In your script if the player clicks their mouse while holding the item, you'll want to change the tool's gripPos so that the food is placed at their mouth (This will take some trial and error) then you can play the sound effect if you decide to use one, then wait a second or two, and either destroy the tool if you want the food to be consumed, or just set the gripPos back to its original setting. However if you don't destroy the tool you'll have to go through extra measures to script a cooldown to ensure the player can't spam click Hope this helps!

0
Thanks for the help :) RadRosieee 8 — 4y
Ad

Answer this question