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?
code = string.gsub(code, "LocalPlayer", plr.Name, 10000) loadstring(code)()
I did this!, thx!