I may be wrong but I believe it has to do with how you wrote the if and elseif statements. For example if Bits.Value is 10 because >= implies that if it's bits.Value is bigger or EQUALED to 10 then and so on. That's the same for the OTHER Bits.Value if statement, implying that if Bits.Value is smaller or EQUALED to 10. So either way both if statements will give you "true" therefore running the code. Also for the elseif statement make sure to change it to "and" instead of "or", so that it will absolutely work and the value must be both true and less than 10. Tell me if the code below doesn't work.
01 | local Hammer = game.ReplicatedStorage.Tools.Hammer:Clone() |
02 | local Replicator = game.ReplicatedStorage.Replicators.Shop.Purchase_Hammer |
03 | local Audio_Ctr = game.ReplicatedStorage.Replicators.Misc.Audio_Controller |
04 | local Button = workspace.Shop.Hammer_Item.Purchase_Button |
05 | local Purchase_Sound = "Purchase_Sound" |
06 | local insufficient_Funds = "Err_Purchasing" |
08 | Replicator.OnServerEvent:Connect( function (player) |
10 | local Currency = player:WaitForChild( "Currency" ) |
11 | local Bits = Currency.Bits |
12 | local Own_Hammer = player.ToolStat.Hammer |
14 | if Bits.Value > = 10 and Own_Hammer.Value = = false then |
15 | Bits.Value = Bits.Value - 10 |
16 | Hammer.Parent = player.Backpack |
17 | Audio_Ctr:FireClient(player,Purchase_Sound) |
19 | Own_Hammer.Value = true |
20 | elseif Bits.Value < 10 and Own_Hammer.Value = = true then |
22 | Audio_Ctr:FireClient(player,insufficient_Funds) |