Weird problem with a script

so im trying to make this script working but when i test, it prints OLD values, even though the values are changed on the server i have no idea why this is happening can someone help

local AutoControlValue = workspace.ReactorAutoControl.Value
local pressure = workspace.Pressure.Value
local temp = workspace.Temperature.Value
local rate = AutoControlValue

local function controlreactor()
	if pressure >= 6000  and AutoControlValue == 10 then
		print("more pressure")
		pressure = pressure + rate
		print(pressure)
	end
	if temp >= 450 and AutoControlValue == 10  then
		print("more temp")
		temp = temp + rate
		print(temp)
	end
	
end
while wait(5) do
	controlreactor()
	print(temp)
	print(pressure)
end

ig u are trying to access the value instance “Value”. if thats the case, what are u doing is indirect change, setting variables to instances Value property will return an number value. Instead do this

local AutoControlValue = workspace.ReactorAutoControl.Value
local pressure = workspace.Pressure
local temp = workspace.Temperature
local rate = AutoControlValue

local function controlreactor()
	if pressure >= 6000  and AutoControlValue == 10 then
		print("more pressure")
		pressure.Value = pressure.Value + rate
		print(pressure.Value)
	end
	if temp >= 450 and AutoControlValue == 10  then
		print("more temp")
		temp.Value = temp.Value + rate
		print(temp.Value)
	end
	
end
while wait(5) do
	controlreactor()
	print(temp.Value)
	print(pressure.Value)
end
1 Like
local function controlreactor()
	local AutoControlValue = workspace.ReactorAutoControl.Value
	local pressure = workspace.Pressure.Value
	local temp = workspace.Temperature.Value
	local rate = AutoControlValue

	if pressure >= 6000  and AutoControlValue == 10 then
		print("more pressure")
		pressure = pressure + rate
		print(pressure)
	end
	if temp >= 450 and AutoControlValue == 10  then
		print("more temp")
		temp = temp + rate
		print(temp)
	end
	
end
while wait(5) do
	controlreactor()
	print(temp)
	print(pressure)
end

thanks, i got it working now after a few adjustments

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.