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

Sup, I have a problem... Mind helping me out?

I wanted to make that when an object aka: Ball touches an specific part, then it will play the sound. But not when the player touches the Part but only the part.

local part = script.Parent


part.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
		local sound = script.Parent.Sound

		if not sound.IsPlaying then
			sound:Play()
		end
	end
end)

1 comment

0

In the future, please include the specific question you have in the question title.

1 answer

✓ Accepted answer

If you want it to be a specific object you could try

script.Parent.Touched:Connect(function(part)
	if part.Name = "SpecificPartIWant" then
		local sound = script.Parent.Sound
		
		if not sound.IsPlaying then
			sound:Play()
		end
	end
end)

1 comment

0

Thank! It worked but you forgot to add another "=" by if part.Name = "SpecificPartIWant" then it should be if part.Name == "SpecificPartIWant" then

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