Why does this not work?

I can’t figure out what the problem is!

local plr = game.Players.LocalPlayer

local chr = plr.Character

local plrgui = plr.PlayerGui

---- Numbers ----

local one = 1

local two = 2

local three = 3

local four = 4

local five = 5

local six = 6

local seven = 7

local eight = 8

local nine = 9

local ten = 10

function onHit()
	if plrgui.BLACKJACK.BLACKJACKFRAME.Hit.TextTransparency == 0 then
		plrgui.BLACKJACK.BLACKJACKFRAME.FirstCard.Text = math.random(one,two,three,four,five,six,seven,eight,nine,ten)


You’re calling the function in the Connect method parenthesis when you should be just passing the function name instead. If you were to call it, it would pass what it returns to the Connect method call (nil) which you should only do if your function is actually returning another function.

To fix your problem, just remove the () after your function’s name in the Connect method call Connect(functionName).

Can you even use math.random with more than 2 numbers? One should be the minumum, and the other maximum, why do you put there 10 numbers?

I’m no expert in scripting, and I’m aware this doesn’t answer your question, but I couldn’t help but notice all of the variables.

A much more efficient way of doing this would be
plrgui.BLACKJACK.BLACKJACKFRAME.FirstCard.Text = math.random(1,10)
rather than using all of the variables you have.

1 Like

I’m sorry, but have you perhaps changed your topic? That’s what I’m looking at, and I definitely don’t understand what you want to do with it.