Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how do i know when to use things like game.workspace.part?

Asked by 5 years ago

i have been watching scripting videos and i do not understand when i will need to use these can someone please give me an example?

0
If you have a part in workspace called "Part", you can change that part's properties (colour, size, position, etc) with a script. LawlR 182 — 5y
0
game.Workspace.Part is how you get that part in a script. Make sure there aren't more than one parts called the same thing. LawlR 182 — 5y
0
how do i know when to use part when scripting? EzireBlueFlame 14 — 5y
0
https://www.youtube.com/watch?v=sGS0WZgh3SE i suggest looking at this, and look at 2:56 User#23365 30 — 5y
0
Here is a Youtube playlist that should help you: https://www.youtube.com/playlist?list=PLXX6hhg4CysYf0M-_GtCEOgGlkBfrXsoJ LawlR 182 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Ok, so game.Workspace.part (or whatever the part is called) is like a scripting tree, for lack of a better term, of categorization. What I mean is, game is the overall category that includes everything in the game, workspace is a category inside the game which has most of the things that you have made for the game (parts, models, even some scripts). So when you would use this is when you are trying to do something with or to a part that is located in the workspace, whether it is changing the part's properties or having something happen to is or whatever you want to do. In order to get the specific part that you want to affect in the script, you have to put game.workspace.Part (if the part's name is part). If the part that you want is called "Trees" then you would say game.workspace.Trees and then you could do whatever you want to that part. It is basically a way of getting a specific part through a script to change or do something to that part. You can also do this for other categories within the game category, such as the StarterGui section (game.StarterGui.(name of the GUI). I hope this helps, if anything is still unclear feel free to comment below and I'll try to clarify.

1
try put formatting in ur answer, like code blocks and highlights User#23365 30 — 5y
Ad
Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Basically everytime you want to reference something inside the workspace, you will use

game.Workspace.YourThingYouWantToReference

so for example, say you wanted to reference a brick inside the workspace folder with a script.

You would do this:

local variable = game.Workspace.Brick -- this is a variable, which means we have now referenced the thing you wanted to call out.

--now you can do whatever you want with that variable(Brick) through a function!

So everytime you want to reference something inside the workspace folder, use game.workspace.

game = the actual game

workspace = folder inside of the game in the "Explorer" tab inside 'View' at the top of studio

0
workspace isn't a folder User#19524 175 — 5y
0
I know.. I was explaining it as one, but i know its a service MusicalDisplay 173 — 5y

Answer this question