Im going to be simple and clear, I already know the jist of LUA, whats the best way to learn roblox’s side of coding, like events and stuff. I’ve got no clue where to start. Also as a beginner what events and stuff should I know? Please link any forum posts or anything in the comments that can help me become a pro scripter!
Well if you look around in dev forum, you might just find some really useful information, also: Custom Events and Callbacks | Documentation - Roblox Creator Hub
Just use the API reference for the most exact details you can get about Roblox datatypes.
The API is very confusing for me
There’s only a few “global” events you should know for a start, they are all part of either RunService (see: RenderStepped
and Heartbeat
) or UserInputService (see: InputBegan
). To use any of these events, you need a LocalScript
in a place where it can run (the easiest way is to make one inside StarterPlayer.StarterPlayerScripts
).
Roblox runs pretty much automatically, which is why you can make entire games with minimal to no scripts whatsoever. A player controller, characters, rendering and the physics engine are all already part of your game and do not need to be initialized, changed or accessed, so there’s no global server-side event you need to subscribe to.
Almost all other events are part of non-abstract instances (abstract ones being Services) such as for a single, defined part getting touched → Touched
. Try to make a Script inside a part in your workspace, and paste this code:
function f(hitPart)
print(hitPart .. " has touched the script part!")
end
script --Reference to the game object ("Source container") that this code is in
.Parent --Field of any Instance that describes its parent in the game hierachy
.Touched --The "Touched" event of the Part the script is in
:Connect(f) --Whenever the event happens, function f will be executed.
--Each event has arguments it passes into the function it executes.
--"Touched" supplies one argument, being the part that touched the subject part.