I’m trying to make a granny-accurate game. I’m trying to make the item dropping system where it’ll play sound when it hit the ground. The problem is. I’ve managed to make the dropping system, but I don’t know how to make it play sounds when it hits the ground.
I wanted to try using .Touched but I wanted a more advanced method. I need to know what I neeed.
Have a script inside the tool that listens for .Touched when anything touches the tools model. Then check if the part that hit it has an attribute that you will add to valid parts that you want it to make a sound when hit called “FloorSound” or whatever and if so just play a sound.
For something simple as such making it more complex would be making it better
You could have a localscript that raycasts down and determine the time before it hits the ground, wait the time, and then play the sound.
To determine the time before reaching the ground, you would need a constant (which’ll include gravity, default 196.2) for the falling speed and multiply that by the distance between the tool and the ground.
I would recommend localscript over serverscript for this because it’ll be more accurate on the timing.
You could raycast down from the tool’s handle every frame and see if the bounding box of the tool collides with the ground by checking the distance of the raycast. Though if you want something more rough but more performant you can use what @Redluo suggested.
You could use a shapecast every frame that goes in the same direction and length as the parts velocity and then just play the sound when it hits something (also playing the sound one frame earlier will compensate player’s ping if you will do it on the server)
For example: (Inside RunService heartbeat on the server)
local Cast = workspace:Shapecast(Part, Part.AssemblyLinearVelocity, RayParams)
if Cast ~= nil then
PlaySound()
end