Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i detect when a sound's soundid is changed?

1 answer

✓ Accepted answer

You almost got it in that DevForum post. All you have to do is add is make a .Changed function, add a property variable, and check if that variable is SoundId!

Example Code of a Part inside Workspace with a Sound object:

game:GetService("Workspace").Part.Sound.Changed:Connect(function(property)
	-- The property variable is what was changed
	if property == "SoundId" then
		print("SoundId has changed!")
		-- Put your code here
	end
end)

If this helped please accept this answer!

3 comments

0

workspace is a global variable...no need to make it fancy

0

I like do to getservice i think its cleaner cause you have to use getservice on other things so

0

You can also use GetPropertyChangedSignal to shorten the code a bit. This way there would be no need for the if statement.

This discussion is preserved as it was. New answers, comments, and votes are closed.