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

Variable and script questions?

So I'm creating this script that a vehicle will only move when you press 'R' to start it. The delay is about 4 seconds because of the sound it makes. Second question, how do I make a global variable (as in it can be called from different scripts.) Thanks

2 answers

I don't quite understand what your first question is.

As for your second one, a global variable is defined with "_G." before the variable name.

For example, if you wanted to make a variable x into a variable that can be called from other scripts, you would make it _G.x

function keydown(key)
  if key == "r" then
    wait(4)
	--Right here, add your car movement properties.
  end
end

game.Players.LocalPlayer:GetMouse().KeyDown:connect(keydown)

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