[50 ROBUX FOR SOLUTION] Help with Weigh tables

Hello! I need help with my wheel spin table. Basically I need to make a weight table for the wheel but do not know how to do it. First person to give me a correct answer will receive 50 robux

Module Script:

local rewards = {
	1,
	2,
	3,
	4,
	5,
	6,
	7,
	8
}

return rewards

Script inside Starter GUI

local REWARD_DEGREE = 45
local wheel = script.Parent.WheelBackground.WheelPart
local spin = script.Parent.WheelBackground.Buttons["Spin!"]
local rewardsModule = require(game:GetService("ReplicatedStorage").SpinnerRewards)
local fullSpins = 4
local TweenService = game:GetService("TweenService")
local Weight = 0
spin.MouseButton1Down:Connect(function()
	local buttonDebounce = false
	local randomRewardIndex = rewardsModule[math.random(1, #rewardsModule)] 
	local targetRotationAngle = (randomRewardIndex-1) * REWARD_DEGREE
	local endRotation = -((360 * -fullSpins) + (REWARD_DEGREE) * (randomRewardIndex - 1))
	local tween = TweenService:Create(wheel, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Rotation = endRotation})
	
	if buttonDebounce == false then
		
		
		buttonDebounce = true
		wheel.Rotation = 0
		local SpinSound = script["Random/Wheel Spin"]
		SpinSound:Play()
		tween:Play()
		wait(3)
		buttonDebounce = false
		print(rewardsModule[randomRewardIndex])
	end
end)

I need it so I can choose the chance of the player landing on that reward

Right now I am trying to solve the problem you are having right now but in the meantime you can debug it by printing through different sections of the script.

1 Like

ah,

In randomRewardIndex = rewardsModule[math.random(1, #rewardsModule)]

remove the one might solve it just having #rewardsModule. I think this because you refer 1 twice. Its clear that the min number is 1 in the table (module script)