Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make music play for local player?

Asked by 10 years ago

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.

0
Insert the sound into the player's PlayerGui or Backpack and play it in there. FearMeIAmLag 1161 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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

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. Defaultio 160 — 10y
Ad

Answer this question