Using Events for Interactive Games

With events, you can respond to actions in Roblox, for example when someone presses a button or a game starts. This makes your game lively and exciting!

Here's how:

  1. Understand the event: An event is like a signal that says, "Something just happened!" For example, clicking a button.
  2. Connect the event: You connect a function to an event so your script knows what to do when the event is triggered.
  3. Write the function: A function contains the code that runs when the event occurs – for example, displaying a message or moving a part.
  4. Use an example: Use the .Touched event to react when a player touches a part.
  5. Test: Start your game in Studio and try out if your event reacts as expected.

With events, you can make your game interactive and exciting – try it out now!

-- Dieses Script kommt in einen Part im Workspace
local part = script.Parent

-- Funktion, die ausgeführt wird, wenn der Part berührt wird
local function onTouched(otherPart)
    print(otherPart.Name .. " hat den Part berührt!") -- Nachricht in der Konsole
end

-- Event mit Funktion verbinden
part.Touched:Connect(onTouched)