[OPEN SOURCE] Music Command [Group Locked & Non Group Locked]

This is a script for users who want to have a command: for example ‘!bob’ to start and audo and ‘!stopbob’ to stop an audio.

Non Group Rank Locked

--Credit Kieranl29 /Intorsetorpolice1 - Popsiz Parlor! --

--Command Varable

local Commands = {
	StartCommand = "!bob", -- Command To start the sound
	EndCommand = "!stopbob", -- Command TO stop the sound.
}

local SoundId = "rbxassetid://9076279762" --The ID of the sound.

--Creating the sound instance.
local sound = Instance.new("Sound")
sound.Parent = workspace
sound.SoundId =  SoundId
sound.Volume = 0.5
sound.PlaybackSpeed = 0.5

--Detecting a player being added to the server.
game.Players.PlayerAdded:Connect(function(Player)
	--Detecting chat messages.
	Player.Chatted:Connect(function(chat)
		--making the chat messages lower case
		local ChatLower = string.lower(chat)
		
		if string.match(ChatLower, Commands.StartCommand) then --compairing chat messages to the command
			sound:Play() --playing the sound
			sound.Looped = true -- making it loop
		end
		if string.match(ChatLower, Commands.EndCommand) then --compairing chat messages to the command
			sound:Pause() -- stopping the sound
				sound.TimePosition = 0 -- removing the sound / resetting the system. 
		end
	end)
end)

Group Rank Locked
--Credit Kieranl29 /Intorsetorpolice1 - Popsiz Parlor! --

local groupids  = {
	group1 = 15053292, --group 1's id
	group2 = 15004815  -- group 2's id
}
local requiredrankids = {
	group1 = 251, -- required rank in group 1's ID
	group2 = 5, -- required rank in group 2's ID
} 

--Command Varable
local Commands = {
	StartCommand = "!bob", -- Command To start the sound
	EndCommand = "!stopbob", -- Command TO stop the sound.
}

local SoundId = "rbxassetid://9076279762" --The ID of the sound.

--Creating the sound instance.
local sound = Instance.new("Sound")
sound.Parent = workspace
sound.SoundId =  SoundId
sound.Volume = 0.5
sound.PlaybackSpeed = 0.5

--Detecting a player being added to the server.
game.Players.PlayerAdded:Connect(function(Player)
	--Detecting chat messages.
	Player.Chatted:Connect(function(chat)
		--making the chat messages lower case
		local ChatLower = string.lower(chat)
		if Player:GetRankInGroup(groupids.group1) >=  requiredrankids.group1 or Player:GetRankInGroup(groupids.group2) >= requiredrankids.group2 then
		if string.match(ChatLower, Commands.StartCommand) then --compairing chat messages to the command
			sound:Play() --playing the sound
			sound.Looped = true -- making it loop
		end
		if string.match(ChatLower, Commands.EndCommand) then --compairing chat messages to the command
			sound:Pause() -- stopping the sound
				sound.TimePosition = 0  -- removing the sound / resetting the system. 
			end
		end
	end)
end)

[IF LESS THEN 2 GROUPS JUST REMOVE: [ On Line 32]

or Player:GetRankInGroup(groupids.group2) >= requiredrankids.group2
Would / Do you use this in your game?
  • Yes
  • No

0 voters

Feell free to use it!

Signed:
Kieranl29
Popsiz Parlor Senior Developer

6 Likes

Please comment any questions / Comment or concernes below here… If you want roblox @Staff feel free to lock the topic if you deem it is needed.

1 Like

I can use it if you make a version with gamepass :hugs:

2 Likes

Drop me a dm and ill do it kieranl29_#3816