I'm trying to do a script builder, instead of game.Players.LocalPlayer to game.Players.Xx_XSanderPlayXx.
this is what i tried
function Run(f, plr)
local unfunction,message = loadstring(f)
if not unfunction then
return nil, message
end
local oldEnvironment = getfenv(unfunction)
local NewEnvironment = setmetatable({}, {
__index = function(_, k)
if k:lower() == "localplayer" then
print(k)
oldEnvironment[k] = plr.Name
return oldEnvironment[k]
else
return oldEnvironment[k]
end
end
})
setfenv(unfunction, NewEnvironment)
unfunction()
end
it only works with game.Players[LocalPlayer].
Can someone help me please?

1 comment
local plr = game.Players:WaitForChild("Xx_XSanderPlayXx") Waits until you load