Multiplication in Lua

I feel dumb for not knowing how to properly format multiplication in Lua but this should be simple for anyone else to answer

local T1 = game.Teams["Blue Bombers"]
local T2 = game.Teams["Red Raiders"]
--teams and stuff obv

while workspace.GameMode.KOTH.Value == true do --checks to see if gamemodes is KOTH
	repeat
	T1.Points.Value = (10 * T1.Cap.Value) --multiplies the Number of people capping the point on team one by 10 every 5 seconds
	T2.Points.Value = (10 * T2.Cap.Value) --same thing but for team 2
	wait(5)
	until workspace.GameMode.KOTH.Value == false --repeats until the round is over
end

(the code doesnt work)

1 Like

What exactly isn’t working? Is it erroring or it’s not doing something that it’s supposed to?

Also, could you elaborate more on what this script does? The comments doesn’t really explain much.

1 Like

T1.Points.Value = T1.Points.Value + (10 * T1.Cap.Value)
or
T1.Points.Value += (10 * T1.Cap.Value)

It’s some kind of score system for a KOTH round yes?

1 Like

It just doesn’t update the score no errors or anything but to be fair i haven’t really used multiplication up to this point

yes this is a script for a KOTH type round its only supposed to update the score

your solution doesn’t seem to work but what do you think is preventing the script from updating the values?

Does T1.Cap.Value get changed? What script changes it?

a script inside of a part updates the Cap value when a player touches it and it works just fine

sounds like the code might not even run

Try printing something like “run code” just before the wait(5)

Or you can simplify the condition temporarily for debugging, instead of

while workspace.GameMode.KOTH.Value == true do
    repeat --round code
    until workspace.GameMode.KOTH.Valu == false
end

use

while true do
    -- round code here
end

To see if the problem is your logic or your actual code

oh looks like you were right the print statement never fired

so, what should i do to fix this then?

wait accually nevermind i managed to get the print statement to firebut the rest still doesnt seem to work

try this:

while wait(5) do
  if workspace.GameMode.KOTH.Value then
    T1.Points.Value = T1.Cap.Value * 10
    T2.Points.Value = T2.Cap.Value * 10
  end
end

okay so i tweaked my code a little and implemented this and worked absolutely fine so thanks for the help!

local T1 = game.Teams["Blue Bombers"]
local T2 = game.Teams["Red Raiders"]

while wait(1) do
	if workspace.GameMode.KOTH.Value then
		repeat
			T1.Points.Value = T1.Points.Value + T1.Cap.Value * 10
			T2.Points.Value = T2.Points.Value + T2.Cap.Value * 10
		wait(1)
		until workspace.GameMode.KOTH.Value == false
	end
end