--This script is a enormously shortened script.
--Any of the variables that aren't defined in here are already defined.
--That's why I pointed that out.
local EnemyNumber = workspace.Enemies:WaitForChild("EnemyNumber")
function gamerun()
local TI = BossesFolder.HIM:Clone()
TI.Parent = workspace.Enemies
Enemies.Value += 1
EnemyNumber.Value += 1
local SAUR = BossesFolder.SAUR:Clone()
SAUR.Parent = workspace.Enemies
Enemies.Value += 1
EnemyNumber.Value += 1
end
gamerun() -- starts the function
For context, this is a function that starts the game the moment it is Enabled
. After the player beats the first boss called “TI”, a 2nd boss called “SAUR” spawns after a while. However since I’m showing a heavily shortened script, you will have to assume I already have put in everything, since this post is focusing on the main problem that breaks the entire script and the game for the players, which is EnemyNumber
attempting to increase the 2nd time.
Let’s get straight to the problem, the problem is EnemyNumber.Value
. When I attempt to increase the EnemyNumber
value the 2nd time (below the SAUR
variable), the script returns a error, saying attempt to index number with 'Value'
. I know I wrote mostly all the code and it works but when the function fires off trying to increase the EnemyNumber.Value
the 2nd time, the script returns a error, yet it is written the same way that works for the first time. I do not know why this is the case and I have absolutely 0 idea how to fix the error it gives. If anyone would like to help, please do!