Sound does not play once a specific speed is reached

Hey DevForum :wave:

I need some help for this script:

  1. What do you want to achieve?
    A sound should be played once if a certain speed of a part is reached.

  2. What is the issue?
    My efforts where unsuccessful yet and I don’t really know if there’s a property of a part which could be used to detect a reached speed.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried using different properties such as AssemblyLinearVelocity and AssemblyAngularVelocity and did some research on both of them on the Developer Hub but I could not find my solution. My script can be found here:

print("soundscript active")
if script.Parent.Velocity.Magnitude == 2.5 then
	print("speed reached")
	script.Parent.Sound:Play()
	print("sound played")
end

Thanks!

You mean distance?

local soundPart = path.to.soundPart -- the sound instance parent.
local sound = soundPart.Sound

local thePart = workspace.Part

if (thePart.Position - soundPart.Position).Magnitude <= 2.5 then
    print('distance reached')
    sound:Play()
end

Not quite. Let’s say we have a part. The part accelerates to a specific value. Once the part accelerated to the specific value. The sound would play once.

Try this..

This text will be hidden

Thanks, but it doesn’t work. The output is empty, only the very first print statement is showing up.

1 Like