"Array can't be coerced into a float."

I have received this error ("Array can't be coerced into a float.") while working on my project. Here is the piece of script call that is causing it:

$game_variables[24] = ($game_variables[7] *
0.4) + ($game_variables[6] * 0.3) +
($game_variables[5] * 0.3)+($game_variables
[4])


When that script runs, it produces the error.(It is a common event and I have narrowed it down to this bit in red.)

What I believe the problem is, is that previously I must calculate something else from the same variable with this piece of script call:

$game_variables[4] = ($game_variables[7] *
0.5) + ($game_variables[6] * 0.3) +
($game_variables[5] * 0.2)

As you can see it sets the Variable[4] which is causing the error to occur. I believe it is because the part above which is done prior causes it to be a decimal. Is there anyway I can round it back to the nearest whole number after a calculation?

I know this isn't something most people have encountered, but any help would be appreciated!
It's because of where your code breaks to the next line. Try this instead:

Code:
$game_variables[24] = ($game_variables[7] *0.4) + ($game_variables[6] * 0.3) +($game_variables[5] * 0.3) + $game_variables[4]
spaces between operands are important for ruby to detect and calculate the result.

For example, 2 - 1  will be identified by ruby as "number minus number", but 2 -1 will read to ruby as "number number" because the - suddenly is identified as the negative sign part of the number, not the mathematical minus function...
The script boxes are annoying sometimes, because if you have a long variable name (like $game_variables[whatever]) and it runs off the side of the script box, it will break your script.
Thank you. You guys are the best. Was able to fix my problem. However is there anyway to round with the script call?(Just wondering while we are on the subject)
Put the whole lot in brackets, and add a .to_i or .round at the end. So this:

$game_variables[24] = (($game_variables[7] *0.4) + ($game_variables[6] * 0.3) +($game_variables[5] * 0.3) + $game_variables[4]).to_i.to_i will truncate any decimals (so will round DOWN).round will round up or down
Thank you Shaz, very good help as always.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/array-cant-be-coerced-into-a-float.15186/