How do I execute a string as a piece of code?
For example, if I have:
x = "print('hello')"
is there a function that would let me do something like
run(x)
?
There is a feature in Roblox called "LoadString" in which you can execute code. However, this is used by exploiters to exploit in your game, so please be careful when doing this.
In order to enabled "LoadString", go check the box in the properties of ServerScriptService.
loadstring()
Yes there is, Let's take PlayerAdded
as an example.
Your function:
function printing(String) print(String) end
PlayerAdded
: So when a player is added, it will call the function above ^^ and print the String
that is written in the parameter of the called function below vv
Players.PlayerAdded:Connect(function(player) printing(player.Name.." has joined the server!") end)
Comment if there is any confusion.