There is an Instance of Sound in the player and I want to change the name of the SoundId.
Here is the script for the new Instance for the new player.
function onPlayerEntered(newPlayer)
wait(5)
local s = Instance.new("Sound", newPlayer)
s.Name = "Music"
print("1")
s:Play()
print("2")
s.SoundId = "http://www.roblox.com/asset/?id=142896835"
s.Volume = 0.7
s.Looped = true
print("3")
end
game.Players.ChildAdded:connect(onPlayerEntered)
I want the SoundId to change when the player touches a brick, but it doesn't seem to work.
function onTouch(hit)
print("4")
local s = hit.Parent:findFirstChild("Music")
print("5")
s.SoundId = "http://www.roblox.com/asset/?id=175664876"
end
script.Parent.Touched:connect(onTouch)
It returns this; * Workspace.MusicChaingeBrick.SoundScript:5: attempt to index local 's' (a nil value)*; when the code reaches the change of the SoundId.
