I made a part that when you touch it, music is supposed to start playing. The script is not local and the output says nothing. Help?
local debounce = true script.Parent.Touched:connect(function(hit) if hit and hit.Parent:FindFirstChild('Humanoid') and debounce then debounce = false local player = game.Players:GetPlayerFromCharacter(hit.parent) local musicplaying = player:WaitForChild('PlayerScripts', 0.1):FindFirstChild('MusicPlaying') if musicplaying.Value == false then local randommusic = math.random(1,3) if randommusic == 1 then game.Workspace.music.lobbymusic.lobbymusic:Play() musicplaying = true elseif randommusic == 2 then game.Workspace.music.lobbymusic.lobbymusic2:Play() musicplaying = true elseif randommusic == 3 then game.Workspace.music.lobbymusic.lobbymusic3:Play() musicplaying = true end end end end)
Put this script inside of the brick. Try this:
local debounce = false script.Parent.Touched:connect(function(hit) if not debounce then debounce = true local check = hit.Parent:FindFirstChild("Humanoid") if check ~= nil then local PlayerName = game.Players:GetPlayerFromCharacter(hit.Parent) local MusicPlaying = PlayerName:WaitForChild('PlayerScripts', 0.1):FindFirstChild('MusicPlaying') if MusicPlaying == false then local Ran = math.random(1,3) if Ran == 1 then game.Workspace.music.lobbymusic.lobbymusic:Play() MusicPlaying = true elseif Ran == 2 then game.Workspace.music.lobbymusic.lobbymusi2:Play() MusicPlaying = true elseif Ran == 3 then game.Workspace.music.lobbymusic.lobbymusic3:Play() MusicPlaying = true end wait(3) end end end debounce = false end)