What do you want to achieve?
I am attempting to sandbox then execute code being sent to the server.
What is the issue?
Instead of returning what it is supposed to return, my loadstring is returning nil, causing an error a few lines of code down:
What solutions have you tried so far?
I’ve tried manipulating the code in any way possible for the error to go away, but it seems to persist.
LoadStringEnabled is in enabled in my game.
My code:
local ScriptData = [[for i = 1, 3 do
spawn(function(math.random(1,2))
repeat wait(1)
local B = Ball()
local z = math.random(workspace.SP2.Position.Z, workspace.SP1.Position.Z)
B.Position = Vector3.new(347.5,379,z)
local s = math.random(8, 20)
B.Size = Vector3.new(s, s, s)
B.BrickColor = BrickColor.random()
B.Anchored = false
until 1 == 2
end)
end]] -- An example script that would typically run normally.
print(ScriptData) -- prints the string above
local f = loadstring(ScriptData) -- returns nil
print(f) -- prints nil???
setfenv(f, {math = math, -- Line 780, where the error is being thrown
print = print,
workspace = ws,
Vector3 = Vector3,
CFrame = CFrame,
wait = wait,
Color3 = Color3,
BrickColor = BrickColor,
ipairs = ipairs,
Enum = Enum,
spawn = spawn,
})
Obviously argument #1, f, is nil and causing the error but I can’t seem to understand why it is doing so.
