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!
01 | -- Made by iiDk |
02 | -- Settings |
03 | local version = "1" |
04 | local plr = owner -- aka iiDkOffical, i like owner more lol |
05 | -- Functions |
06 | local function message(text) -- Sends a message to the server |
07 | local msg = Instance.new( "Message" ) |
08 | msg.Parent = game:GetService( "Workspace" ) |
09 | msg.Text = text |
10 | wait( 3 ) |
11 | msg:Destroy() |
12 | end |
13 | local function playSound(soundCat,soundName,soundId,musicId) -- Plays a sound |
14 | local sound = Instance.new( "Sound" ) |
15 | sound.SoundId = "rbxassetid://" ..soundId |
You are setting msg to a new instance on line 85, so it is not a string by the time it gets to line 87.
To manipulate any string, you need to make sure it's actually a string. You said it is but if you go back to that line, the message is an instance so if you try to "sub" an instance, it won't work.
I think you forgot to do msg.Text
but instead you did msg
alone.
To fix it, change this line in Line 87:
1 | msg.Text = "[lib] " ..string.sub(msg, 14 ) |
To this
1 | msg.Text = "[lib] " ..string.sub(msg.Text, 14 ) |