Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[Rawset] [Edited] Block getfenv()??

It shouldnt print Owner,PlaceId,etc... the rawset should block it.

I would like the function getfenv() to return "Blocked" as a string instead of getting the variables.

Owner = getfenv().owner -- not blocked yet(obv)
PlaceId = game.PlaceId
PlaceName = game.Name
PlaceJobId = game.JobId
PlaceDesc = game.MarketplaceService:GetProductInfo(PlaceId).Desc

rawset(getfenv(),'',{'[Rawset] Table does not exist'})  -- This should block getfenv() I think..
-- When I run this on a table it locks it,but then I cant get table main table back. 
table.foreach(getfenv(),print)

4 comments

0

Can you explain precisely what it is that you want to happen, and what is happening instead?

0

using getfenv() with table.foreach you can print ALL the variables in a script. And you can easily steal code like that.

0

I'm not sure how anyone with the power to append your script with code to read the function environment couldn't just read the script they're editing. Perhaps you're calling code created by players and sharing the function environment with them? Besides being dangerous, I don't think you could steal code if you just saw a list of variables (even if you had their values).

0

^, Im trying to block code stealers. Im trying to protect my code.

1 answer

✓ Accepted answer

Would this do what you want?

function getfenv()
	return "Blocked"
end

It overwrites the definition of getfenv so that later on in the script, any attempt to use getfenv() will use your new function instead of the default one.

The rawset you're using just adds a new variable to the environment: a variable with no name with the value of a table with the "[Rawset] Table does not exist" string.

A consequence of the function I've proposed is that table.foreach(getfenv(),print) will error, since getfenv() no longer returns a table.

1 comment

0

Omg.. why didnt I think of this.. XD Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.