I am a novice at Lua & Scripting, Could anyone help me?
✓ ANSWER ACCEPTED
How do I make it so that when a player touches a Part that music plays?
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()
thanks for attending the ted talk
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Add a end) at it