Hello, I've got a block in my Lobby that I want to play random music when touched. I think I'm close to getting this right, but I've misidentified the second line:
00:48:47.197 - Workspace.Lobby.TouchToPlayAudio.Touch to Play Audio:10: attempt to index upvalue 'MusicList' (a number value)
Any thoughts on how to get this going correctly? :) Thanks!
local music ={123456789,123456789,123456789,123456789,123456789,123456789,123456789}
local MusicList = music[math.random(#music)]
local P = script.Parent.Parent
Enabled = true
function onTouched(hit)
if (Enabled == true) then
Enabled = false
MusicList:Play()
P.Name = ""
wait()
P.Name = ""
Enabled = true
end
end
script.Parent.Touched:connect(onTouched)

3 comments
You should not keep adding if's. Use elseif's.
Thank you for the responses. Studio keeps telling me: Touched is not a valid member of Model and then doesn't play. =/
I'm also new to scripting, sorry