I've made an if statement with an elseif statement in a while wait() loop. But only the if statement run because whenever the if statement returns false but the elseif statement returns true it doesn't run the function in the scope of the elseif statement. Here's the code. Also the function is called whenever the player presses E while near the object I set it to.
function RequestGemConvert()
local Coins = 0
local MaximumCoins = game.ReplicatedStorage.ConvertGems:InvokeServer(0,false) -- so we would only invoke it once
script.Parent.GemConverter.Open.Value = true
script.Parent.GemConverter.Background:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Quint",0.5,true)
script.Parent.GemConverter.Background.Add.MouseButton1Click:Connect(function()
Coins = Coins + 1
end)
script.Parent.GemConverter.Background.Subtract.MouseButton1Click:Connect(function()
Coins = Coins - 1
end)
script.Parent.GemConverter.Background.Max.MouseButton1Click:Connect(function()
Coins = MaximumCoins
end)
script.Parent.GemConverter.Background.Min.MouseButton1Click:Connect(function()
Coins = 0
end)
script.Parent.GemConverter.Background.Convert.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer:WaitForChild("Leaderstats").Coins.Value == 0 or Coins < 5 then
module:SendNotification("Error!","You only gave the machine a little amount of Coins! You need to spend 5 Coins or more in this machine to get any amount of Gems!")
else
game.ReplicatedStorage.ConvertGems:InvokeServer(Coins,true)
script.Parent.GemConverter.Background:TweenPosition(UDim2.new(0.5,0,1.5,0),"In","Quint",0.5,true)
module:SendNotification("Awesome!","Successfully converted your coins to Gems!")
script.Parent.GemConverter.Open.Value = false
end
end)
script.Parent.GemConverter.Background.Exit.MouseButton1Click:Connect(function()
script.Parent.GemConverter.Background:TweenPosition(UDim2.new(0.5,0,1.5,0),"In","Quint",0.5,true)
script.Parent.GemConverter.Open.Value = false
Coins = 0
end)
while wait() do
script.Parent.GemConverter.Background.Coins.TextLabel.Text = module:RequestPlaceValue(Coins)
script.Parent.GemConverter.Background.Gems.TextLabel.Text = module:RequestPlaceValue(math.floor(Coins / 5))
if Coins == 0 then -- Working if statement
script.Parent.GemConverter.Background.Subtract.Visible = false
script.Parent.GemConverter.Background.Add.Visible = true
elseif Coins == game.Players.LocalPlayer:WaitForChild("Leaderstats").Coins.Value then -- not working elseif statement
script.Parent.GemConverter.Background.Add.Visible = false
script.Parent.GemConverter.Background.Subtract.Visible = true
else
script.Parent.GemConverter.Background.Add.Visible = true
script.Parent.GemConverter.Background.Subtract.Visible = true
script.Parent.GemConverter.Background.Max.Visible = true
script.Parent.GemConverter.Background.Min.Visible = true
end
if script.Parent.GemConverter.Open.Value == false then
break
end
end
end

2 comments
try using leaderstats instead of Leaderstats in your script
Ummm its only the name that is different. I named it Leaderstats because I don't want player's to know each other's stats