#Why do we put game.Workspace when referencing an object (I dont get the game part)
30 messages · Page 1 of 1 (latest)
** You are now Level 3! **
'game' just means your actual game, the place you're making
Workspace is the physical stuff you can see like parts, characters in the game, the baseplate etc.
the Workspace is inside the game, so you are referencing the game, then the Workspace, then your object
(although you can just use 'workspace' as a shortcut)
the game part is a bit confusing, i know! in roblox, the game object is the root object of the entire game. it's like the top-most container that holds everything else. @trail fern
when you see game.Workspace, it's because the Workspace service is a child of the game object. the Workspace service is responsible for storing all the objects that are currently in the game world, like models, parts, actors, etc.
so, when you want to reference an object in the game world, you need to go through the Workspace service. that's why you see game.Workspace a lot. it's like saying "hey, i want to access an object in the game world, so i need to go through the Workspace service, which is a child of the game object".
think of it like a file system. the game object is like the root directory (e.g. C:\), and the Workspace service is like a subdirectory (e.g. C:\Workspace\). when you want to access a file (object) in that subdirectory, you need to specify the full path, which includes the root directory and the subdirectory (e.g. C:\Workspace\MyObject).
in roblox, the full path would be game.Workspace.MyObject. it's just a way to organize and access objects in the game world!
thanks dude this really helped
@cobalt goblet
One thing
game.Workspace.Part.Transparency = 1 i have this script in server script service
it aint working
the part is staying transparency = 0
ahhh
the issue is that game.Workspace.Part doesn't directly reference a specific part. you need to specify the exact part you want to modify. try this instead:
local part = game.Workspace:FindFirstChild("Part")
if part then
part.Transparency = 1
end
this script finds a part named "Part" in the workspace and sets its transparency to 1. make sure the part exists and has the correct name.
@trail fern
oh, the alvinblox tutorial it worked
Alright
"Part" is the actual name
ya ty
local function addNumbers(num1, num2)
print(num1 + num2)
end
addNumbers(2, 3) -- 5
addNumbers(5, 6, 7) -- 11
addNumbers(9) -- attempt to perform arithmetic (add) on number and nil
why do put local in front of function
cuz
like does that make addnumbers local
@cobalt goblet
?
sorry
