Roblox Guide Help

Wheel Module

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

[dependencies] wheel-module = "release/wheel-module@0.0.1"

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 WheelModule = require(ReplicatedStorage.Packages["wheel-module"]) -- Serves for initialization for both the controller and -- the service depending where it's called.
local WheelService = Knit.GetService("WheelService")

Configuration

A file called WheelModule.config.lua is to be created in ReplicatedStorage/Shared/Configs.

return table.freeze({ Normal = { [1] = { name = "TestMoney", amount = 100, amountType = "Percent", Odds = 10, type = "Currency" }, [2] = { name = "TestPet", amount = 1, amountType = "Fixed", Odds = 10, type = "Item" } }, Premium = { [1] = { name = "TestMoney", amount = 100, amountType = "Percent", Odds = 10, type = "Currency" }, [2] = { name = "TestPet", amount = 1, amountType = "Fixed", Odds = 10, type = "Item" } }, })

Explanation:

  • Index: The index represents the type of wheel

  • Tables: A list of rewards

    • name: The name of the item / currency to give

    • amount: The amount of the item / currency to give

    • type: The type of item to give (Can be anything, it depends on the rest of the code)

    • odds: The chances of said item the drop. The drop rate depends on the total amount (so if all your odds adds up to 100, it will be in %)

    • amountType: Can be used to determine if the reward is to be given in fixed amount or in % of what you currently have.

Usage

Events

  • OnWheelSpin: Triggers when the player start to spin the wheel.

  • OnWheelSpinCompleted: Triggers when the item is sent to client

  • OnWheelSpinCompleted: Triggers when the item is sent to client

Methods

Server Side

Explanation

  • player: The player that spun the wheel.

  • type: The type of wheel to spin


local item = WheelService:Spin(player, "Premium") print(item.name)

    Client Side

    Explanation

    • singleAngleSize: The size of the angle of a single item on the wheel. (They should all be the same)

    • fullSpins: The number of full spin the wheel does before landing on the item.

    • index: The index of the obtained item.


    local angle = GetFinalAngle(35, 4, 2) print("angle: "..angle)
      Last modified: 17 December 2024