I'm creating a Plugin for roblox studio that writes a simple script and puts it in ServerScriptStorage. However, I'm having trouble getting it to work the way I want it too. This is what I have so far...
Script.Source = [====[ local ["game.Workspce.Part.Name"] = game.Workspace.Part print("Done") ]====]
and when I use the plugin the output in ServerScriptStorage is this...
local ["game.Workspace.Part.Name"] = game.Workspace.Part print("Done")
but I want ["game.Workspace.Part.Name"] to be the acually name of the part like this...
local PartName = game.Workspace.Part print("Done")
Is there a way I can make ["game.Workspace.Part.Name"] not be read as a string?
I wouldn't recommend doing this, because dynamically naming variables like this can easily cause problems, however you could do this using getfenv()
like so:
getfenv()[workspace.Part.Name] = workspace.Part print(Part) --> Part
which would define a variable within the function environment that has the same name as the part (in this case, 'Part')
If you found this answer helpful be sure to mark as an answer and upvote!