Hi! I am currently working on a project but I want to create a variable that will not change its original value for anything in the world. Is there any way to do this?
Please be a bit more specific, since I have no idea what you mean by “that will not change it’s origin value from anything in the world”
I’m trying to say that how can I make it so that a variable never changes its value for anything in the world?
He probably means the roblox server.
What do you mean by “anything in the world” you mean all servers or…?
nononono I am trying to say that I want a variable to never change its value for anything in the world, like for example JavaScript “constants”.
If you dont change it it will never change…
is not what I am trying to say. I guess I’m not being more specific :’(
u can achieve this by never setting anything to change that variable (:
and do you perhaps mean it will never change data type??? because if so no the variables are polymorphic as in it will change to whatever datatype u assign it
--notice how when you run this you dont get errors
local LOL = {}
LOL = 2
LOL = "3"
Using a quick google search on constants in javascript, I think he means an immutable variable (like one that you cannot change the value of).
Edit: but then again if you dont try to change the value it will never change.
Blockquote
but then again if you dont try to change the value it will never change.
facts
Exactly, isn’t it unnecessary to make it unchangeable if you wont change it. No one else can change it anyway.
I want this same variable to have it with a fixed value and only fixed, but it is inside a Module and the Exploiters could change its value and that is why I am looking for an “immutable” variable.
Unless you are checking client sided, it wont replicate.
ohhhhh I understand, thank you! I did not know that exploiters are run from the client, I thought they could be run from both sides hahaha.
Const or similar won’t prevent exploiters from modifying it. You could replicate the behavior though via a proxy table, giving it a metatable with a __newindex
metamethod to throw an exception. But even then, exploiters still have the upper hand, as they can just use rawset
to bypass __newindex
…
Yes, and this is why people say to never trust the client:
you could just add some code that will repetitively set the variable back so it can’t be changed.