I can't figure out how to fix this. Basically, i'm experimenting by making a basic mha game, and i'm working on a way to switch quirks. whenever I run this script though, I get this error:
Players.Hindile.PlayerGui.quirkSpin.Main.Spin.TextButton.LocalScript:28: attempt to index a number value
This is my code.
local quirks = {
{Quirk = "Erasure", Rarity = "Legendary", Chances = 0.05},
{Quirk = "WarpGate", Rarity = "Rare", Chances = 0.15}
}
local ok = game.Players.LocalPlayer.PlayerGui.quirkSpin.Main.OK
local main = game.Players.LocalPlayer.PlayerGui.quirkSpin.Main
local white = game.Players.LocalPlayer.PlayerGui.quirkSpin.Main.White
local spin = game.Players.LocalPlayer.PlayerGui.quirkSpin.Main.Spin
local amountofspins = 20
local spintime = 5
function insert()
for i = 1,#quirks do
local times = quirks[i].Chances * 100
repeat
table.insert(quirks,quirks[i])
times = times - 1
wait()
until times == 0
wait()
end
end
insert()
spin.TextButton.MouseButton1Click:Connect(function()
repeat
white.QuirkDecision.Text = math.random(1,#quirks).Quirk
spintime = spintime - .2
wait(.2)
until spintime == 0
if spintime == 0 then
white.QuirkDecision.Text = math.random(1,#quirks).Quirk
end
end)

1 comment
It works perfectly now. Thanks!