of     1   

parasiticplant
#139681723Tuesday, July 08, 2014 9:13 PM GMT

I have made a LocalScript called "Script" and I have put a sound named "Sound" in it. It is supposed to play music only for the local player when the brick that it is placed in is touched. Here is the script in the LocalScript file: function onTouched(part) script.Sound:Play() end script.Parent.Touched:connect(onTouched) For some reason, the script doesn't play the sound when the brick is touched. Could someone please help me or give me a script that would work?
fireblade2
#139682070Tuesday, July 08, 2014 9:16 PM GMT

You need to use a server script for objects in the server because local scripts only run in the client. The script you have should clone the sound into the player's Backpack or PlayerGui so only they hear the sound
parasiticplant
#139682890Tuesday, July 08, 2014 9:23 PM GMT

Could you please give me a script that would do that? Thanks in advance.
fireblade2
#139683777Tuesday, July 08, 2014 9:30 PM GMT

function onTouched(part) local sound = script:FindFirstChild("Sound") if sound then if part.Parent:FindFirstChild("Humanoid") then local player = game.Players:FindFirstChild(part.Parent.Name) if player:FindFirstChild("PlayerGui") then local sound2 = sound:Clone() sound2.Parent = player:FindFirstChild("PlayerGui") sound2:Play() end end end end script.Parent.Touched:connect(onTouched) --Sounds are not removed from the player when played, so the player is able to collect an abundance of sounds

    of     1