I’ve been stuck on this code for quite a while and don’t seem to get the problem.
Anyone know the problem?
local button = script.Parent
local num = 0
button.Text = "JOIN " .. num .. "/2"
button.MouseButton1Click:Connect(function()
num += 1
if button.Text == "JOIN 2/2" then
print("ENOUGH PLAYERS!")
end
end)
what changed here is that the function tostring changes the number value to a string value.
Other thing is that when adding a value you always have to do it like this: num = num +1
also i see that you are not updating the players number, Heres the correct Version
local button = script.Parent
local num = 0
button.Text = "JOIN " … num … “/2”
button.MouseButton1Click:Connect(function()
if button.Text == “JOIN 2/2” then
print(“ENOUGH PLAYERS!”)
else
num = num +1
button.Text = “JOIN “…tostring(num)…”/2”
print(button.Text)
end
end)
local button = script.Parent
local num = 0
button.Text = "JOIN " .. tostring(num) .. "/2"
button.MouseButton1Click:Connect(function()
if num == 2 then
print("pro gaming we have enough players")
else
num += 1
end
end)
local button = script.Parent
local num = 0
button.Text = "JOIN " .. num .. "/2"
button.MouseButton1Click:Connect(function()
if num == 2 then
print("ENOUGH PLAYERS!")
else
num += 1
end)
Try This, now it checks if the number its 2 or other to then proceed to add the number.
local button = script.Parent
local num = 0
button.Text = "JOIN " … num … “/2”
button.MouseButton1Click:Connect(function()
if button.Text == “JOIN 2/2” then
print(“ENOUGH PLAYERS!”)
elseif num ~= 2 then
num = num +1
button.Text = “JOIN “…tostring(num)…”/2”
print(button.Text)
end
end)