If statement not working?

the script is in a gui same with the textlabel and value

maybe thats why.? since its in a screengui

No, no, its not because of that, I tried a test without any issue
image

maybe you’re overwriting the variable?

you can anyways change the variable name to PlayerCount like I did

this is the script:

local Players = game:GetService("Players")
local TotalPlayers = #Players:GetPlayers()

game.ReplicatedStorage.RemoteEvents.Skip.OnServerEvent:Connect(function()
	script.Parent.Parent.Skips.Value = script.Parent.Parent.Skips.Value + 1
end)

while task.wait(0.1) do
	TotalPlayers = #Players:GetPlayers()

	script.Parent.Parent.SkipButton.Text = "Skips("..script.Parent.Parent.Skips.Value.."/"..TotalPlayers..")"
	if script.Parent.Parent.Skips.Value == TotalPlayers then
		print("works")
	end
end

the other skipscript is the button value going up
image

wait what did you change to playercount?

I actually don’t know the issue with the variable, but this is the script I’ve used to test:

local Button = script.Parent
local Value  = script.Value
local Label = script.Parent.Parent.TextLabel

local Players = game:GetService("Players")
local PlayerCount = #Players:GetPlayers()

Button.MouseButton1Click:Connect(function()
	Value.Value = Value.Value + 1
end)

while task.wait(0.1) do
	PlayerCount = #Players:GetPlayers()
	Label.Text = "Skips("..Value.Value.."/"..PlayerCount..")"
	
	if Value.Value == PlayerCount then
		print("worked")
	end
end

i copied everything. The only thing I can think is the probably is the value. What value did you use?

A number value
(--------------------)

i used it before so am confused on what the problem is

GOT IT TO WORK! Seems like it was the value though am confused since I was using a number value before? maybe I got mistaken on the value.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.