Roblox Guide Help

Area Module

In your wally.toml file, add this to your dependencies:

[dependencies] area-module = "release/area-module@0.0.10"

You have two solutions to import this module, depending if you wish to import the Controller or the Service on your own, or if you let the module give you the right code.

local AreaModule = require(ReplicatedStorage.Packages["area-module"])
local AreaService = Knit.GetService("AreaService")

A file called AreaModule.config.lua is to be created in the folder ReplicatedStorage/Shared/Configs.

return table.freeze({ ["Area1"] = CFrame.new(100, 10, 100), ["Area2"] = workspace.RandomPart -- etc.. -- Can either take a part or a CFrame })

Explanation:

  • Each element can either be a CFrame or a Part and will represent a destination for the zones.

Usage

List of events:

  • OnTableUpdated: triggers whenever the area's table is updated (When areas are unlocked).

Usage

-- On the client AreaController.OnTableUpdated:Connect(function(zones: {}) print("New table of unlocked areas :"..zones) end)

    Methods

    Client

    AreaService:GetUnlockedZones(player)

    Explanation

    • player: The player to fetch the zones from.

    local unlockedAreas = AreaService:GetUnlockedZones(player) if unlockedAreas["Rockstar"] then print("Rockstar is unlocked !") end

      Server

      AreaService:GetUnlockedZones(player)

      Explanation

      • player: The player to fetch the zones from.

      local unlockedAreas = AreaService:GetUnlockedZones(player) if unlockedAreas["Rockstar"] then print("Rockstar is unlocked !") end

      • player: The player to check the zone for.

      • areaToCheck: The area to check.

      local areaToCheck = "rockstar" AreaService:IsAreaUnlocked(player, areaToCheck)

        Server

        AreaService:UnlockZones(player, ...)

        Explanation

        • player: The player to fetch the zones from.

        • ...: a table of zones names to be unlocked.

        local areasToUnlock = {"DanceZone", "RockstarZone"} AreaService:UnlockZones(player, areasToUnlock)

          Client

          AreaService:RequestTeleport(player: Player, destination: string)
          • player: The player to fetch the zones from.

          • destination: The destination to teleport to.

          local destination = "RockstarZone" AreaService:RequestTeleport(player, destination)
            Last modified: 28 November 2024