How to fix elseif statement not running?
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.
01 | function RequestGemConvert() |
03 | local MaximumCoins = game.ReplicatedStorage.ConvertGems:InvokeServer( 0 , false ) |
05 | script.Parent.GemConverter.Open.Value = true |
07 | script.Parent.GemConverter.Background:TweenPosition(UDim 2. new( 0.5 , 0 , 0.5 , 0 ), "Out" , "Quint" , 0.5 , true ) |
09 | script.Parent.GemConverter.Background.Add.MouseButton 1 Click:Connect( function () |
13 | script.Parent.GemConverter.Background.Subtract.MouseButton 1 Click:Connect( function () |
17 | script.Parent.GemConverter.Background.Max.MouseButton 1 Click:Connect( function () |
21 | script.Parent.GemConverter.Background.Min.MouseButton 1 Click:Connect( function () |
25 | script.Parent.GemConverter.Background.Convert.MouseButton 1 Click:Connect( function () |
26 | if game.Players.LocalPlayer:WaitForChild( "Leaderstats" ).Coins.Value = = 0 or Coins < 5 then |
27 | 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!" ) |
29 | game.ReplicatedStorage.ConvertGems:InvokeServer(Coins, true ) |
30 | script.Parent.GemConverter.Background:TweenPosition(UDim 2. new( 0.5 , 0 , 1.5 , 0 ), "In" , "Quint" , 0.5 , true ) |
31 | module:SendNotification( "Awesome!" , "Successfully converted your coins to Gems!" ) |
32 | script.Parent.GemConverter.Open.Value = false |
36 | script.Parent.GemConverter.Background.Exit.MouseButton 1 Click:Connect( function () |
37 | script.Parent.GemConverter.Background:TweenPosition(UDim 2. new( 0.5 , 0 , 1.5 , 0 ), "In" , "Quint" , 0.5 , true ) |
38 | script.Parent.GemConverter.Open.Value = false |
44 | script.Parent.GemConverter.Background.Coins.TextLabel.Text = module:RequestPlaceValue(Coins) |
45 | script.Parent.GemConverter.Background.Gems.TextLabel.Text = module:RequestPlaceValue(math.floor(Coins / 5 )) |
48 | script.Parent.GemConverter.Background.Subtract.Visible = false |
49 | script.Parent.GemConverter.Background.Add.Visible = true |
50 | elseif Coins = = game.Players.LocalPlayer:WaitForChild( "Leaderstats" ).Coins.Value then |
51 | script.Parent.GemConverter.Background.Add.Visible = false |
52 | script.Parent.GemConverter.Background.Subtract.Visible = true |
54 | script.Parent.GemConverter.Background.Add.Visible = true |
55 | script.Parent.GemConverter.Background.Subtract.Visible = true |
56 | script.Parent.GemConverter.Background.Max.Visible = true |
57 | script.Parent.GemConverter.Background.Min.Visible = true |
60 | if script.Parent.GemConverter.Open.Value = = false then |