← Back to journey

Who can enter? Reuse your rule

v6 · Activity 11 of 14 · or · and · not · boundaries · 11 min Learning simulation

Chapter outline
Loading draft…
One step at a time

A visitor can enter by either route: reaching the required level or holding a pass. >= includes the exact level boundary; or accepts either true condition.

The browser checks a returned boolean for different visitors. This Learning simulation is not a running Roblox experience or a multiplayer security system.

Run code tests the same solution with the reviewed inputs shown below. The Learning simulation displays the actual returned values, including incorrect results. It does not test Roblox physics, networking or persistent game data.

Your task

Implement canEnter(playerLevel, requiredLevel, hasPass). Return a boolean: allow a visitor at or above the required level, or a visitor with a pass. Keep the final return canEnter so the checker can try the visible cases and additional boundaries. This is a Learning simulation, not a Roblox gate.

Interface: canEnter(playerLevel, requiredLevel, hasPass) -> boolean

InputExpected
Level 4, requirement 5, no pass4, 5, falsefalse
Level 5, requirement 5, no pass5, 5, falsetrue
Level 7, requirement 5, no pass7, 5, falsetrue
Level 2, requirement 5, pass2, 5, truetrue
Syntax in this activity

New syntax: or, and, not

Earlier ideas used here
  • booleans
  • comparison
  • if-elseif-else
  • functions
  • parameters
  • return-values
What this exercise checks

Actual returned results for every test input · the stated behavior · extra output allowed.

Successful execution is required. A compile error, runtime error or execution limit never completes this task.

Whitespace, matching single or double quotes, and different variable names are allowed. Output-only tasks accept any valid Luau solution meeting the displayed result and value types. Construct tasks use the stated straight-line form.

Explain this code

Select a word or symbol in this authored example. Your editor draft stays unchanged.

  canUseBenchhasReservation, isOpenDay
     hasReservation  isOpenDay

 canUseBench
Choose a highlighted part to see what it means.
Free experiment

This is a private experiment copy. It does not replace your answer or complete the activity.

These inputs apply when your scratchpad returns the function described by the activity interface.

Luau keyword highlighting · Ctrl/⌘ + Enter: Run · Esc: leave editor
Experiment Output

Your output will appear here.

Your goal

Implement canEnter(playerLevel, requiredLevel, hasPass). Return a boolean: allow a visitor at or above the required level, or a visitor with a pass. Keep the final return canEnter so the checker can try the visible cases and additional boundaries. This is a Learning simulation, not a Roblox gate.

Run code to see what happens. Check solution to test the activity.

Reset starter

Replace this code with the starter? Download your draft to keep a copy.

Code

Luau
Luau keyword highlighting · Ctrl/⌘ + Enter: Run · Esc: leave editor

Your output will appear here.

Ready