Runner = game.workspace.Runner Choose = math.random(1,3) A=1 B=2 if Choose == 1 then game.workspace.Runner.Position = Vector3.new(20,20,20) end if Choose == 2 then game.worksapce.Runner.Position = Vector3.new(30,30,30) end if Choose == 3 then game.workspace.Runner.Postion = Vector3.new(40,40,40) end
Please read all of the answer, as I put a lot of time and effort into it and it would be highly appreciated
First thing's first
Indenting,
Indenting is an important part of coding that allows other scripters to see what it is you're trying to code. Without indenting, it makes it extremely hard to read. Please indent your code by using the TAB key while in Roblox Studio so that we may better read your code. If you don't know how to properly indent, I will provide you with an example.*
local var = "Help me please...." function printMsg(msg) if msg == ("Help me please....") then --Indented because it's in a function print(msg) --Indented because it's the inside of if else --Indented back because it's part of the if statement, so it lines up with if print("The message isn't what it says it is =(") --Indented because it's the inside of if end --Indented to line up with the if end --Indented to line up with the function printMsg(var) --Does not need indenting because it's not in anything
An easier way to think of indenting is like a forest. Each function is it's own tree, and
everything inside of the function is it's own branch. When you're connecting a
smaller branch to a big branch, you'll put the code inside the code. So for instance,
an if
statement is a bigger branch, you'll attach some little branches of code to that
so it knows what it's supposed to do, then you'll have a bigger branch next to that called else, and you'll make little branches of code for the else.
Organizing and cleaning your code,
It's helpful to have a cleaned, organized code, not only for you to debug but for others. To do so, it's better to have locals for variables and keep your variables at the beginning of the script unless it is not yet defined. A lot of the organization-based stuff is on you, but indenting and organizing definitely is a must.
FINISHED SCRIPT
local runner = game.workspace:WaitForChild('Runner') --Waits for the runner. function randomNumber(min, max) --math.Random will not update if not in a called function math.random(min, max) end local Choose = randomNumber(1, 3) if Choose == 1 then game.workspace.Runner.Position = Vector3.new(20,20,20) elseif Choose == 2 then game.workspace.Runner.Position = Vector3.new(30,30,30) elseif Choose == 3 then game.workspace.Runner.Postion = Vector3.new(40,40,40) end
The scripting output is also where you're going to find your errors. To enable that, simply go to view tab, and click output.