# This is our main script file.
# Think of it as the "Brain" of the door.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our "Device" - the physical door in the game.
# We link this in the editor later.
DoorDevice := class(creative_device):
# This is a VARIABLE.
# It holds the door's current state (open/closed).
# Default is false (closed).
Is_Open: bool := false
# This is a FUNCTION.
# It's a block of code that runs when something happens.
OnBegin<override>()<suspends>:void=
# We listen for the "OnInteract" event.
# This fires when a player presses the interact button (E/Click)
# while looking at the door.
for player := range GetInteractingPlayers():
# Toggle the variable
Is_Open = !Is_Open
# If it's now open, play the open animation
if Is_Open:
DoorDevice.PlayAnimation("Open")
else:
DoorDevice.PlayAnimation("Close")
Verse Library
verse
01 Device
Toggles a door open or closed state whenever players interact with it via input.
verse-library/using-residential-galleries-in-fortnite-creative/01-device.verse