Hi. I have a script that basically makes it easier to add sound effects to stuff for when it hits something hard. The script goes inside the part you want to emit noise for when it gets hit. Now, I have already achieved the main idea of the script, but I’m looking to solve the problem of sounds emitting from the limb even before it hits the ground because when in mid-air, it passes the velocity threshold and it’s colliding with a moving body part and making a sound. I want it to ignore all collisions within the player model. This is my script.
local soundTable = script.Sounds:GetChildren() -- yooo automated
script.Parent.Touched:Connect(function()
if script.Parent.Velocity.Magnitude >= 40 then
local randomSound = soundTable[math.random(1, #soundTable)]
local clonedSound = randomSound:Clone()
clonedSound.Parent = script.Parent
clonedSound:Play()
wait(3)
clonedSound:Destroy()
end
end)
I have tried tinkering around with :GetDescendants() to get all of the parts within the model (Just script.Parent.Parent:GetDescendants()) however I cannot wrap my head around how to keep the code going in terms of the touch indicating part of the script.