Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make my textlabel have a key generated via text button?

I've made a key generator for 1-time uses and it only errors, without making the textlabel have its key.

Why?

local keygen = {
	math.random(1,10000)
}
script.Parent.MouseButton1Click:Connect(function(generatekey)
	local genkey = generatekey
		generatekey = true
		if generatekey == true then
			script.Parent.Parent.TextLabel.Text = keygen
			end
end)

Heres an error: 20:46:57.567 - Players.ChronoFantastic.PlayerGui.ScreenGui.TextButton.Script:8: bad argument #3 to 'Text' (string expected, got table)

4 comments

0

Oh and, i want to let you know that the keygen basically has numbers and letters.

0

turn keygen into a function that returns the random number, and i have no idea what you meant by "not string" (btw generatekey will always be true since you set it on the previous line, this is not how you debounce anything)

0

what?

0

oh wait no youre printing the address of the table "keygen" let me post an answer

1 answer

✓ Accepted answer

here:

local function keygen()
	return math.random(1,10000)
end

script.Parent.MouseButton1Click:Connect(function(generatekey)
    local genkey = generatekey
        generatekey = true
        if generatekey == true then
            script.Parent.Parent.TextLabel.Text = keygen()
        end
end)

1 comment

0

Works, thank you radusavin366.

This discussion is preserved as it was. New answers, comments, and votes are closed.