Changing toStrings?

Hi - Sorry if I’m using the wrong method; I’m trying to advance my knowledge of Scripting.

So, I’m working on a Wand / Magic system right now that is Chat based, however, the way it works is it checks to see if a Function of the Spell’s name resides within the required Module, so:

local Spell = "Lumos"
local Module = require(Module)
if Module[Spell] ~= nil then
end

What I’m looking to is allow this to work for spells with spaces, as I can’t have a function with a space in suches as:

Magic.Protego Maxima = function()
end

So when noting “Spell” as: “Protego Maxima” How can I convert this into “Protego_Maxima” so that the function can be:

Magic.Protego_Maxima = function()
end
Magic["Protego Maxima"] = function()
end
2 Likes

I understand that, but I’m looking to change the gathered info of the Players chat from “Protego Maxima” into “Protego_Maxima”

In that case,

(string.gsub(str, " ", "_"))
1 Like
string.gsub(str, " ", "_");
std::string string.gsub(std::string s, std::string pattern, auto repl);
// Returns a copy of s in which all 
// (or the first n, if given) occurrences of the
// pattern have been replaced by a replacement 
// string specified by repl, which can be a string, 
// a table, or a function. 
// gsub also returns, as its second value, 
// the total number of matches that occurred.