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 music play for local player?

So this is the script :

debounce = false
function onTouched(hit) 
if debounce == false then
debounce = true
local s = Instance.new("Sound") 
s.Name = "Sound" 
s.SoundId = "http://www.roblox.com/asset/?id=148101943" 
s.Volume = 1 
s.Looped = false 
s.archivable = false 

s.Parent = game.Workspace

wait(0)

s:play() 
end
end

script.Parent.Touched:connect(onTouched)

It works for all people for example: Someone touches the music brick and it play for all players, but I want it to make play for the one who touched it. Local player.

Kthxbye.

1 comment

0

Insert the sound into the player's PlayerGui or Backpack and play it in there.

1 answer

✓ Accepted answer

On line 12 set the parent to game.Workspace.CurrentCamera!

1 comment

1

If this is in a Local Script and the script is in Workspace, as the last line suggests, this will not work because Local Scripts can only run in characters or player instances. You are right that a local script is needed, though, to be able to get the Workspace.CurrentCamera. OP, you'll need to make this a local script and put it in something like StarterGui and change the last line.

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