Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make this script execute on command like ":music 294300429" but also plays that id?

local Part = Instance.new("Part", game.Workspace[""..game.Players.LocalPlayer.Name])
Part.CanCollide = false
Part.Shape = "Block"
Part.Anchored = true
Part.Locked = true
Part.Name = "MusicItem"
Part.Transparency = 0.5
Part.Material = "Neon"
Part.BrickColor = BrickColor.new("Toothpaste")


local Sound = Instance.new("Sound", Part)
Sound.SoundId = "https://www.roblox.com/asset/?id=264409463" 
Sound.Looped = true
Sound.Pitch = 1
Sound.Name = "Sound"
Sound.Volume = 1
Sound:Play()

game:GetService("RunService").RenderStepped:connect(function()
Part.CFrame = CFrame.new(game.Workspace[""..game.Players.LocalPlayer.Name].HumanoidRootPart.Position) * CFrame.new(0,5,0)
end)
while true do wait()
local alg = math.floor(Sound.PlaybackLoudness)/120
Part.Size = Vector3.new(.6+alg,.6+alg,.6+alg)
end

2 comments

2

Don't just post code. Give us explaination of what is broken, and what you've tried to fix it. We cant just do stuff with random code.

0

Im not trying to fix anything I was asking if there is any way to make script execute on command.

2 answers

This may help you, if you know how to read scripts. Chatted Event of Player Aaand String Manipulation for get Command and ID from Chatted Event's parameter.

Here's a small example

local Admins = {
	["Yo mama"] = true;
	["Yo dada"] = true;
}
 
game.Players.PlayerAdded:connect(function(player)
	if Admins[player.Name] then 
		player.Chatted:connect(function(msg)
			if string.sub(msg,1,6) == ":music" do
				Sound.SoundId = "https://www.roblox.com/asset/?id="..string.sub(msg,8)
				--And continue this code please.
			end
		end)
	end
end)

1 comment

1

Love the yomama and yodada XD

If single player says "runcode" run the code.

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "MrNicNac" then
        player.Chatted:connect(function(msg)
	if msg == "runcode" then
		local Part = Instance.new("Part", game.Workspace[""..game.Players.LocalPlayer.Name])
Part.CanCollide = false
Part.Shape = "Block"
Part.Anchored = true
Part.Locked = true
Part.Name = "MusicItem"
Part.Transparency = 0.5
Part.Material = "Neon"
Part.BrickColor = BrickColor.new("Toothpaste")


local Sound = Instance.new("Sound", Part)
Sound.SoundId = "https://www.roblox.com/asset/?id=264409463" 
Sound.Looped = true
Sound.Pitch = 1
Sound.Name = "Sound"
Sound.Volume = 1
Sound:Play()

game:GetService("RunService").RenderStepped:connect(function()
Part.CFrame = CFrame.new(game.Workspace[""..game.Players.LocalPlayer.Name].HumanoidRootPart.Position) * CFrame.new(0,5,0)
end)
while true do wait()
local alg = math.floor(Sound.PlaybackLoudness)/120
Part.Size = Vector3.new(.6+alg,.6+alg,.6+alg)
end
	end
        end)
    end
end)
local Part = Instance.new("Part", game.Workspace[""..game.Players.LocalPlayer.Name])
Part.CanCollide = false
Part.Shape = "Block"
Part.Anchored = true
Part.Locked = true
Part.Name = "MusicItem"
Part.Transparency = 0.5
Part.Material = "Neon"
Part.BrickColor = BrickColor.new("Toothpaste")


local Sound = Instance.new("Sound", Part)
Sound.SoundId = "https://www.roblox.com/asset/?id=264409463" 
Sound.Looped = true
Sound.Pitch = 1
Sound.Name = "Sound"
Sound.Volume = 1
Sound:Play()

game:GetService("RunService").RenderStepped:connect(function()
Part.CFrame = CFrame.new(game.Workspace[""..game.Players.LocalPlayer.Name].HumanoidRootPart.Position) * CFrame.new(0,5,0)
end)
while true do wait()
local alg = math.floor(Sound.PlaybackLoudness)/120
Part.Size = Vector3.new(.6+alg,.6+alg,.6+alg)
end

If that does not work then please reply. If you want it for a group of people then use the following:

local allowedplayers = {
	["John Doe"] = true;
	["Jane Doe"] = true;
}
 
game.Players.PlayerAdded:connect(function(player)
	if allowedplayers[player.Name] then 
		player.Chatted:connect(function(msg)
			if msg == "runcode" then
			local Part = Instance.new("Part", game.Workspace[""..game.Players.LocalPlayer.Name])
Part.CanCollide = false
Part.Shape = "Block"
Part.Anchored = true
Part.Locked = true
Part.Name = "MusicItem"
Part.Transparency = 0.5
Part.Material = "Neon"
Part.BrickColor = BrickColor.new("Toothpaste")


local Sound = Instance.new("Sound", Part)
Sound.SoundId = "https://www.roblox.com/asset/?id=264409463" 
Sound.Looped = true
Sound.Pitch = 1
Sound.Name = "Sound"
Sound.Volume = 1
Sound:Play()

game:GetService("RunService").RenderStepped:connect(function()
Part.CFrame = CFrame.new(game.Workspace[""..game.Players.LocalPlayer.Name].HumanoidRootPart.Position) * CFrame.new(0,5,0)
end)
while true do wait()
local alg = math.floor(Sound.PlaybackLoudness)/120
Part.Size = Vector3.new(.6+alg,.6+alg,.6+alg)
end
	end
        end)
    end
end)
local Part = Instance.new("Part", game.Workspace[""..game.Players.LocalPlayer.Name])
Part.CanCollide = false
Part.Shape = "Block"
Part.Anchored = true
Part.Locked = true
Part.Name = "MusicItem"
Part.Transparency = 0.5
Part.Material = "Neon"
Part.BrickColor = BrickColor.new("Toothpaste")


local Sound = Instance.new("Sound", Part)
Sound.SoundId = "https://www.roblox.com/asset/?id=264409463" 
Sound.Looped = true
Sound.Pitch = 1
Sound.Name = "Sound"
Sound.Volume = 1
Sound:Play()

game:GetService("RunService").RenderStepped:connect(function()
Part.CFrame = CFrame.new(game.Workspace[""..game.Players.LocalPlayer.Name].HumanoidRootPart.Position) * CFrame.new(0,5,0)
end)
while true do wait()
local alg = math.floor(Sound.PlaybackLoudness)/120
Part.Size = Vector3.new(.6+alg,.6+alg,.6+alg)
end
		end)
	end
end)

If you would like it for a rank in a group then on the first code set the player name line to the following:

local Rank = Player:GetRankInGroup(GROUPID) >= [Role Number (No brakets)(ex: GetRankInGroup(GROUPID) >= 50)]

Make sure to add this at the very top of the code:

game.Players.PlayerAdded:connect(function(Player)

1 comment

0

Ah sorry. My solution will not work. You want an experienced script. That requires using sub stuff which few know how to do.

This discussion is preserved as it was. New answers, comments, and votes are closed.