I'm trying to make a message command for when you say lib.cmds:msg.hi and it'd say "[lib] hi" but instead it errors out. Please help!
-- Made by iiDk
-- Settings
local version = "1"
local plr = owner -- aka iiDkOffical, i like owner more lol
-- Functions
local function message(text) -- Sends a message to the server
local msg = Instance.new("Message")
msg.Parent = game:GetService("Workspace")
msg.Text = text
wait(3)
msg:Destroy()
end
local function playSound(soundCat,soundName,soundId,musicId) -- Plays a sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://"..soundId
sound.MaxDistance = "99999999999999999999999999999999999999"
sound.Volume = 1
sound.Parent = game:GetService("Workspace").Base
sound.Name = "lib.musicplayer"
sound.Looped = true
sound:Play()
message("[lib] Now playing "..soundCat..": "..soundName.." (ID: "..soundId.." libID: "..musicId..")")
end
-- Main Commands
plr.Chatted:Connect(function(msg)
if string.sub(msg,1,4) == "lib." then -- Finds main library
if string.sub(msg,5,16) == "musicplayer:" then -- Makes sure if it's music player
if string.sub(msg,17,21) == "play." then
local assetname = game:GetService("MarketplaceService"):GetProductInfo(string.sub(msg,22))
playSound("Custom",assetname.Name,string.sub(msg,22),"0")
else
if string.sub(msg,17,20) == "stop" then
local success, message = pcall(function()
--Top
game:GetService("Workspace").Base["lib.musicplayer"]:Destroy()
message("[lib] Music stopped")
--Bottom
end)
if not success then
local msg = Instance.new("Message")
msg.Parent = game:GetService("Workspace")
msg.Text = "[lib] No music playing"
wait(3)
msg:Destroy()
end
end
end
else
if string.sub(msg,5,8) == "help" then
message("lib.help: lib.musicplayer:play.id - plays the sound id specified | lib.musicplayer:stop - stops sounds playing | lib.help - shows commands")
else
if string.sub(msg,5,9) == "cmds:" then
if string.sub(msg,10,14) == "kill." then
local success, message = pcall(function()
--top
if game:GetService("Players"):FindFirstChild(string.sub(msg,15)).Character.Humanoid then
game:GetService("Players"):FindFirstChild(string.sub(msg,15)).Character.Humanoid.Health = 0
end
--bot
end)
if not success then
local msg = Instance.new("Message")
msg.Parent = game:GetService("Workspace")
msg.Text = "[lib] No player found. Try their full username."
wait(3)
msg:Destroy()
end
else
if string.sub(msg,10,12) == "re." then
local success, message = pcall(function()
--top
game:GetService("Players"):FindFirstChild(string.sub(msg,13)):LoadCharacter()
--bot
end)
if not success then
local msg = Instance.new("Message")
msg.Parent = game:GetService("Workspace")
msg.Text = "[lib] No player found. Try their full username."
wait(3)
msg:Destroy()
end
else
if string.sub(msg,10,13) == "msg." then
local msg = Instance.new("Message")
msg.Parent = game:GetService("Workspace")
msg.Text = "[lib] "..string.sub(msg,14)
wait(3)
msg:Destroy()
end
end
end
end
end
end
end
end)
message("[lib] Script has been loaded! "..plr.Name.." has libraryCommands. Say lib.help for help. ")
message("[lib] Note: you can't do anything bad so don't even think about it. Version "..version)

2 comments
no i'm trying to set the message of it
By setting msg=Instance.new("Message"), you overwrite the string that it used to be. On line 87, you call string.sub(msg,14), but you just set msg to something that is not a string, so it wont work.