generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Is it possible to change the environment of the Command Bar?

Previous Thread :: Next Thread 
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
25 May 2015 05:49 PM
So for example, if I was to type:

setfenv(0,{})
print("Hi")

into the command bar, I would get an error about print not existing, which means it works.

However, if I type: print("Hi") again, it works just fine.
Why is this?
Report Abuse
LilSoundGeezer is not online. LilSoundGeezer
Joined: 20 Dec 2013
Total Posts: 223
25 May 2015 05:52 PM
Idk I'm learning scripting, any advice? Or sources I could use? Anything is appreciated.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 May 2015 05:53 PM
Well the command bar is just loadstring'd so doing that you aren't actually changing the env. of the command bar.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
25 May 2015 05:55 PM
Quick, pcall(getfenv)

There's a problem with pcalling getfenv, in that it doesn't behave right.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 May 2015 06:01 PM
I don't think it's really a problem, just how getfenv and pcall work.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
25 May 2015 06:06 PM
@cnt
But it still stores variables in a table environment, and Im trying to change that environment to the corescript environment.
Don't ask how, but I have access to it lol.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 May 2015 06:09 PM
Well yeah the environment is the global environment for loadstring, so:

loadstring("x = 5;")() would add it to the global environment, no matter if the function it was called in had a different environment.

local test = function()
loadstring("x = 5;")();
print(x); -- nil
end;

setfenv(test, {loadstring=loadstring;print=print;});
test();
print(x); -- 5

That should print what I commented (inb4spellingerror)
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
25 May 2015 06:11 PM
Oh wow.
Yeah that might work lol.
Report Abuse
Froast is not online. Froast
Joined: 12 Mar 2009
Total Posts: 3134
25 May 2015 06:14 PM
The Command Bar uses game.LogService.ExecuteScript
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
25 May 2015 06:15 PM
^
That's for the in-game console that allows the client to request for the server to execute code.
Report Abuse
Froast is not online. Froast
Joined: 12 Mar 2009
Total Posts: 3134
25 May 2015 06:21 PM
Which command bar wasn't specified, I should've assumed it was the studio one though.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image