If statements not working

local FMove = true


local function UIChange(Text, Bool)
	
	if Bool ~= "C" then
		FMove = true
		print("woah")
	end
	if Bool == "C" then
		FMove = false
	end
	
	print(Bool)
end

Event.OnClientEvent:Connect(UIChange)

server:

statusText = "SURVIVORS WINS"
statusUpdate:FireAllClients(statusText, "B")
2 Likes

Try

if value ~= something then
    -- code
else
   -- different code ig
end
3 Likes

Just rewrite the if statements

If Bool == C then
   FMove = false
else
   FMove = true
   print(“Woah”)
end

print(Bool)

My guess is that since there are 2 if statements, the script treats them differently. You should put them into the same statement if you are checking the same variable

3 Likes

Can you show an example what’s wrong with the scripts? Like the output? That would help us understand what you’re talking about

1 Like

Are there any errors? Is anything printed at print(Bool)? I would try doing this:

Event.OnClientEvent:Connect(function(text, bool)
    UIChange(text, bool)
end)

Try doing: FMove = not bool it’s simple and might help

Clarify what you mean by doesn’t work.

Assuming Event in the provided LocalScript and statusUpdate in the provided ServerScript are the same RemoteEvent, there is nothing wrong with the code, but instead the instance whose scripts are parented is your problem.

Relocate where the scripts are, because there are certain instances where LocalScripts or ServerScripts don’t work when parented to. (For example, ServerScripts don’t work in ReplicatedStorage, and LocalScripts don’t work outside a player’s character.)

1 Like
local Event = game.ReplicatedStorage:WaitForChild("RoundEvent")
----
local StatusUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("StatusUI")
local Status = StatusUI.CanvasGroup.TextLabel
local Frame = StatusUI.Frame
----
local A = Frame.A
local B = Frame.B
local C = Frame.C
----
local tween = game:GetService("TweenService")
local info = TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
--
local TGoal1 = UDim2.fromScale(0.5, -3.11)
local FGoal1 = UDim2.fromScale(0.5,0.037)
local TGoal2 = UDim2.fromScale(0.5, 0.797)
local FGoal2 = UDim2.fromScale(0.5, 0.076)

----
local T1 = tween:Create(Status, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out),{Position = TGoal1}) -- Text Up
local T2 = tween:Create(Status, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),{Position = TGoal2}) -- else
local T3 = tween:Create(Frame, TweenInfo.new(0.48, Enum.EasingStyle.Back, Enum.EasingDirection.Out),{Position = FGoal1}) -- frame up
local T4 = tween:Create(Frame, TweenInfo.new(0.48, Enum.EasingStyle.Back, Enum.EasingDirection.Out),{Position = FGoal2}) -- else

local T5 = tween:Create(Frame, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),{Transparency = 1})

local FMove = true


local function UIChange(Text, Bool)
	wait(.1)
	print(Bool)
	if Text == "WAITING FOR PLAYERS..." then Status.Text = Text return end
	if not FMove then Status.Text = Text end
	if FMove == true then 
		T3:Play() 
		T1:Play()

	end

	T1.Completed:Wait()
	if FMove == true then 
		T2:Play()
		T4:Play()
	end
	Status.Text = Text
	if Bool == "B" then
		print(Text)
		C.Enabled = true
		local c = tween:Create(C, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),{Transparency = 1})
		c:Play()
		B.Enabled = true
		local b = tween:Create(B, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),{Transparency = 0})
		b:Play()
		b.Completed:Wait()
		C.Enabled = false

	elseif Bool == "A" then
		print(Text)
		A.Enabled = true
		local a = tween:Create(A, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),{Transparency = 0})
		a:Play()
		local c = tween:Create(C, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),{Transparency = 1})
		c:Play()
		a.Completed:Wait()
		C.Enabled = false
	else
		A.Enabled = false
		B.Enabled = false
		C.Enabled = true
		C.Transparency = NumberSequence.new(0)
	end
	if Bool ~= "C" then
		FMove = true
		print("woah")
	end
	if Bool == "C" then
		FMove = false
	end
	
	print(Bool)
end

Event.OnClientEvent:Connect(UIChange)

even when the if state ment should

if Bool ~= "C" then
		FMove = true - doesnt do this
		print("woah") -- do this  but doesnt
	end
	if Bool == "C" then
		FMove = false
	end

I have to ask … why are you using the word Bool here … Is this being set to true or false someplace.
Normally a Bool is true or false … as a Bool is what they are called. You could use the word Bool as a string but that seems odd. If this is being used as a actual bool (true or false) that would explain what’s going wrong here.

1 Like
local Event = game.ReplicatedStorage:WaitForChild("RoundEvent")
local StatusUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("StatusUI")
local Status = StatusUI.CanvasGroup.TextLabel
local Frame = StatusUI.Frame

local tween = game:GetService("TweenService")
local TGoal1 = UDim2.fromScale(0.5, -3.11)
local FGoal1 = UDim2.fromScale(0.5, 0.037)
local TGoal2 = UDim2.fromScale(0.5, 0.797)
local FGoal2 = UDim2.fromScale(0.5, 0.076)

local T1 = tween:Create(Status, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = TGoal1})
local T2 = tween:Create(Status, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Position = TGoal2})
local T3 = tween:Create(Frame, TweenInfo.new(0.48, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = FGoal1})
local T4 = tween:Create(Frame, TweenInfo.new(0.48, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = FGoal2})

local function UIChange(Text, Bool)
	if Text == "WAITING FOR PLAYERS..." then
		Status.Text = Text
		return
	end

	if not FMove then
		Status.Text = Text
	end

	if FMove then
		T3:Play()
		T1:Play()
	end

	T1.Completed:Wait()

	if FMove then
		T2:Play()
		T4:Play()
	end

	Status.Text = Text

	if Bool == "B" then
		C.Enabled = true
		tween:Create(C, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Transparency = 1}):Play()
		B.Enabled = true
		tween:Create(B, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Transparency = 0}):Play()
		B.Completed:Wait()
		C.Enabled = false
	elseif Bool == "A" then
		A.Enabled = true
		tween:Create(A, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Transparency = 0}):Play()
		tween:Create(C, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Transparency = 1}):Play()
		C.Enabled = false
	else
		A.Enabled = false
		B.Enabled = false
		C.Enabled = true
		C.Transparency = NumberSequence.new(0)
	end

	FMove = Bool == "C" and false or true
end

Event.OnClientEvent:Connect(UIChange)

This is adjusted 2x

Try changing it to this for the client event reciever:

local FMove = true


local function UIChange(Text, Bool)
	
	if Bool ~= "C" then
		FMove = true
		print("woah")
	end
	if Bool == "C" then
		FMove = false
	end
	
	print(Bool)
end
-- Change Starts:
Event.OnClientEvent:Connect(function(txt, condition)
    UIChange(txt, condition)
end)

It could be that the function is not receiving the data as its not being sent to it perhaps?

1 Like

Yeah ik what a book is. It was a book before but I just changed it to string values so I didn’t change the variable name