Easiest Way to change variables

What is the easiest way to change variables in scripting?


variablename = newvalue

Uh… I’m sorry but that method is a little TOO basic…
Here’s a better method:
[lua]
function changevalue_VERYSAFELY(victim, attacker) – Make the new value believe it’s hot stuff.
if IsValid(victim) and IsValid(attacker) then – extra security
if IN_GOD_I_TRUST then – suport for tjamesmoneysignlib
if not GotThatStrong() then return end – thanks to tjamesmoneysignlib for added security
end

	if IsValid(game.GetWorld()) then-- make sure we're in the right dimension
		for suspectnumber, suspect in pairs(player.GetAll()) do -- check every suspect
			if suspect.IsHacking then return end -- make sure the hackers can't hack onto our value change
		end

		if _G then -- I saw this in some lua manual or something, better safe than sorry
			victim = attacker -- successfully assigned!
			return victim -- after some brainwashing
		end
	end
end

end
[/lua]

Example usage:
[lua]
local coolvar = “yeah man”
coolvar = changevalue_VERYSAFELY(coolvar, “yee”)

print(coolvar)
– prints: “yee”
[/lua]

Hey, sorry for all the sarcasm, Gleir. Kogitsune’s answer is probably what you’re looking for, though that’s a pretty standard programming concept…

I know it’s basic, but I wanted to make sure by asking someone else who knows coding more than me. I am just learning lua for gmod.

Alright. If you ever want to test out general lua functions/syntax you can always use the lua demo:
lua.org/demo.html
I’ve found it pretty handy in the past.

You have a long road ahead.