Hello, I am having problems with this code right here.
local t = script.Parent.Text
while true do
wait(0.1)
workspace.Part.Script.Source = t
end
There is a textbox for players to type code into, but it says:
The current identity (2) cannot Source (lacking permission 1) - Client - LocalScript:5
I don’t get the permission part.
Okay, I have tested it in a serverscript same result.
I believe using .source with a local script and applying it to another script which is server-sided will result in lacked permission.
If I believe so, this might have to called from a server script. As a local script cannot change the source code of a server script, if this were true, all of our games would easily be hacked.
TenBlocke
(Decablocks)
March 24, 2022, 12:39am
#3
You cannot change any serverscript’s source code from a localscript
Schkr1
(Schkr1)
March 24, 2022, 12:40am
#4
https://developer.roblox.com/en-us/api-reference/property/Script/Source
Script.Source
can not be used in scripts or local scripts, only the command bar and plugins.
Is there any way to change the source code through script?
TenBlocke
(Decablocks)
March 24, 2022, 12:41am
#6
Only through a plugin or the command bar
Schkr1
(Schkr1)
March 24, 2022, 12:43am
#7
While the game is running and not in studio, I don’t believe it is possible, but why would you even need to do that?
I am making a game where you can code parts. It’s meant for the people on mobile.
You can use loadstring()
. But it only works on server scripts.
You have to enable it under ServerScriptService
local string = [[
local x = 6
local y = 9
print(x + y)
]]
local code = loadstring(string)
code() -- 15
from the example, I loadstring-ed the string, and it returned a function so I called the function.
Forummer
(Forummer)
March 24, 2022, 1:26am
#10
I’m not even sure why it’s a SSS property, especially considering it enables the loadstring()
global function for all server scripts (regardless of their location).
local f = loadstring("print('Hello world!')")
f()