local b = script.Parent local guess = b.Parent.Guess local nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} local num = nums[math.random(1, #nums)] b.MouseButton1Click:connect(function() if guess.Text == num then print("yay") end end) print(num)
The problem is, this doesn't print "yay" when i enter the correct bumber, why is this?
The problem lies in line 7. I'm going to assume that b
is a TextButton object. Look for "Text", the third entry down in "Properties." Next to it says "string." That means this property accepts strings. So you can do either the following: convert guest.Text
into a number, or convert num
into a string.
if tonumber(guess.Text) and tonumber(guess.Text) == num then
Or
if guess.Text == tostring(num) then