INFO: The script won't update "Wave Value" in Workspace. The script is in ServerScriptService. The time is shortened for testing it should be longer when finished same with the for loop.
local ServerStorage = game.ServerStorage local wave = workspace.Wave.Value function CreateWave() local WaveClone = ServerStorage.Wave:Clone() WaveClone.Parent = game.Workspace end wait(1) while true do for i = 1, 1 do if math.random(1, 5) == 2 then local EClone = ServerStorage.EWave:Clone() EClone.Parent = game.Workspace else if math.random(1, 10) == 2 then local SnowClone = ServerStorage.GiantSnow:Clone() SnowClone.Parent = game.Workspace else CreateWave() end end wait(math.random(5, 15)) end wave = wave + 1 wait(1) end
wave
variable is a reference to the actual property of the IntValue
. If the value of the IntValue
changes, the variables you have defined won't update; only its Value
property will change. In order to fix this, you can remove the wave
variable and only make direct accesses to the Value
property of the IntValue
. You could also modify the variables to hold the IntValue
object itself.local ServerStorage = game:GetService("ServerStorage") local wave = game.Workspace.Wave -- refer to object! function CreateWave() local WaveClone = ServerStorage.Wave:Clone() WaveClone.Parent = game.Workspace end wait(1) while true do for i = 1, 1 do if math.random(1, 5) == 2 then local EClone = ServerStorage.EWave:Clone() EClone.Parent = game.Workspace else if math.random(1, 10) == 2 then local SnowClone = ServerStorage.GiantSnow:Clone() SchanowClone.Parent = game.Workspace else CreateWave() end end wait(math.random(5, 15)) end wave.Value = wave.Value + 1 -- directly access property wait(1) end
local t1 = { foo = "abc", bar = 123, foobar = true } local t2 = { foo = "abc", bar = 123, foobar = true } local t1reference = t1 --t1 & t1reference are the same table now, but t2 is different t1.foo = "Hello world!" print(t1.foo) --> Hello world! print(t1reference.foo) --> Hello world! print(t2.foo) --> abc
t1
and t1reference
variables both hold the same exact table whilst t2
is a different table even though it holds the same values.local number = 50 local numberVal = num number = 25 print(number) --> 25 print(numberValue) --> 50 local bool1 = false local bool1Val = bool1 bool1 = true print(bool1) --> true print(bool1Val) --> false
numberValue
was set to number
, both variables have different memory and so changing one value does not change the other value. Same for the boolean values.