I'm making a game about invading territories, and since I'm new to coding, I don't fully know how purchases work yet, and my code may not be very neat or compact, but I'm not concerned about those. All I'm concerned about it the fact that this one line of code likes to switch between working and not working. Here's the code:
invade.MouseButton1Click:Connect(function() if military.Text > "500000" and countryname.Text == c1.Text then invframe:TweenPosition(UDim2.new(0.318, 0,1.5, 0), "In", "Back",0.8, true) military.Text = "0" budget.Text = budget.Text * 0.5 c1.Visible = false elseif military.Text < "500000" then nation.Text = c1.Text defeat:TweenPosition(UDim2.new(0.318,0,0.088,0), "Out", "Quint",2, true) start.Visible = false end end)
And here's the problematic line:
budget.Text = budget.Text * 0.5
This line only does it's job like 1% of the time, and when it doesn't, it gives me this error:
Players.AbettrWesley.PlayerGui.MenuGui.MenuFrameOutlineShadow.MenuFrameOutline.MenuFrame.PlayButtonOutlineShadow.PlayButtonOutline.PlayButton.PlayButtonMenuClosingScript:183: attempt to perform arithmetic (mul) on Instance and number
Please let me know what this means and how I can fix it... I've been irritated for days now.