Playing sound when a player touches a part

Hello, I have a script (I followed some of the script from Roblox code sample), but whenever a player touches a part, the sound doesn’t play.
Here is the script:

local players = game:GetService("Players")
local sound = game:GetService("SoundService")

function touched(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		sound.FunArcade:Play()
	end
end

script.Parent.Touched:Connect(touched)

Is there something that I’m doing wrong? Thank you.

1 Like

maybe because humanoid doesn’t exists

try to switch from :FindFirstChildWhichIsA(“Humanoid”) to :WaitForChild(“Humanoid”)? (wait until humanoid exists)

2 Likes

There are a couple of things to check.

  • Check if your IDs are alright
  • Remember that playing sound local requires you to use the SoundService | Roblox Creator Documentation function
  • Check the volume, roll off distance and position if the sound is parented to the workspace.
2 Likes