If and elseif don't work

Hello, I have a problem with the if and elseif, and the problem comes when putting the text in a textLabel because there you choose in which language to put it, but it doesn’t put it and I don’t know what the reason is

server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local FeedPlayerEvent = ReplicatedStorage:WaitForChild("FeedPlayer")

local function PlayerFeed(player, notify)
wait(0.3)
if notify ~= nil then

FeedPlayerEvent:FireAllClients(player.Name, "you winner of the money")
else
FeedPlayerEvent:FireAllClients(player.Name)
end
end

Players.PlayerAdded:Connect(PlayerFeed)
Players.PlayerRemoving:Connect(PlayerFeed)
FeedPlayerEvent.OnServerEvent:Connect(PlayerFeed)

LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

local SettingsData = player:WaitForChild("SettingsData")
local GameSettings = SettingsData:WaitForChild("GameSettings")
local LenguajeValue = GameSettings:WaitForChild("Language")
local FeedEvent = ReplicatedStorage.FeedPlayer

local actionFinish = {}
actionFinish.TextTransparency = 0
actionFinish.BackgroundTransparency = 0.4
local actionEnding = {}
actionEnding.TextTransparency = 1
actionEnding.BackgroundTransparency = 1

local Tweeninfo = TweenInfo.new(0.5)

FeedEvent.OnClientEvent:Connect(function(plr, notify)
	wait()
	local Template = Instance.new("TextLabel")
	Template.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
	Template.Font = Enum.Font.SourceSansBold
	Template.BackgroundTransparency = 1
	Template.TextTransparency = 1
	Template.Text = ""
	local Corner = Instance.new("UICorner", Template)

	if notify ~= nil then
		print(notify)
	else
		for _, players in pairs(Players:GetChildren()) do
			if plr == players.Name then
				if LenguajeValue.Value == "Spanish" then
					Template.Text = plr.. " se unió al juego"
				elseif LenguajeValue.Value == "English" then
					Template.Text = plr.. " joined the game"
				end
			else
				if LenguajeValue.Value == "Spanish" then
					Template.Text = plr.. " se salió al juego"
				elseif LenguajeValue.Value == "English" then
					Template.Text = plr.. " came out to the game"
				end
			end
		end
		Template.Parent = script.Parent
		TweenService:Create(Template,Tweeninfo, actionFinish):Play()
		wait(7)
		local FinishTween = TweenService:Create(Template,Tweeninfo, actionEnding)
		FinishTween:Play()
		FinishTween.Completed:Wait()
		Template:Destroy()
	end
end)
1 Like

The question you asked does not match the code you have provided. You said the text that the ‘person puts into’ the textlabel does not get ‘put in’. This code does not show anything regarding the setting of the value “LanguajeValue”. What changes this value?

mmmmm, the value I use to put the elseif and if, is a StringValue that is used to change the language of the game. If I do everything from the LocalScript with “Players.PlayerAdded” and “Players.PlayerRemoving” it works, but not if I do it from a remote event

Try to debug, set a lot prints seeing if anything is sent wrong

I have tried, however, it doesn’t give print or anything.

Debugging is the process of uncovering bugs and solving them. MiTeX was suggesting that you should add print() throughout the affected code so that you can determine what is actually happening. Put things in the print message, such as the necessary parameters or at least something unique so that you can determine what is happening during runtime.

print(“is this working?”)

2 Likes
if plr == players.Name then
	-- rest of the code...

I believe the problem is here, you never defined the value plr and since it doesn’t exist, the if loop doesn’t run. When you use the == symbol it will return a bool value tht is tru or false. In this case, it returns false as there is no plr value in your script.

This is a better way to solve it:

plr = players.Name
      if plr then

Is this the solution?

3 Likes

You forgot to indent in the server scripts if and else statements. Other than that idk what is wrong. Looks good to me.

No, it is not the solution. The error comes from the if and elseif of the localPlayer (if LanguageValue.Value), not the player I entered.

K
So i didnt provide the rite ans aft3r all hmmm