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 make it so that when a player touches a Part that music plays?

I am a novice at Lua & Scripting, Could anyone help me?

3 answers

✓ Accepted answer
local sound = script.Parent.Sound --The sound object to play

script.Parent.Touched:connect(function(p) --When the parent part is touched
	local human = game.Players:GetPlayerFromCharacter(p.Parent) --Check touching part is part of a Player character
	if human and not sound.IsPlaying then --If player and the sound isn't already playing
		sound:Play() --Play the sound
	end
end)

Be sure to name the sound/music Sound, or to edit the script with the name.

Both the script & sound should be inside the part.

try this

script.Parent.Touched:Connect(function(c)
game.Workspace.Sound:Play()

1 comment

0

Add a end) at it

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