How would I make a temperature changing system?

Basically, what I wanna do is: When the laser power or core power is increased, the core temperature will increase faster but when cooling is activated, the core will heat up slower until it reaches a certain point and starts to decrease faster and faster depending on the level of the coolant and heatant… I hope you understood what I meant!

I would go with this:

Use the .Changed event to detect whenever the laser power/core power changes. You will have a variable defining the speed that will be changed whenever the power changes. You could use some math formula to do that.

Then once it changes, you create a tween and tween the core temperature and have the speed (time) parameter as the speed variable.

Don’t worry, that many tweens wont mess anything up. Once an another tween is created on the same object while the other one is still running, the other one will cancel out and the new one will run instead.

local TweenService = game:GetService("TweenService")

local Speed = 25 -- Default speed, you can set this to whatever you want.
local Addition = 10 -- This is the target temperature for the core
local CoreTemp = -- definition here
local Power = -- definition here

Power.Changed:Connect(function()
local Formula -- some kind of formula to determine the speed of the tween

TweenService:Create(CoreTemp, TweenInfo.new(
    Formula,                        --Speed determined by the math formula
    Enum.EasingStyle.Sine,          --set this as whatever you want
    Enum.EasingDirection.InOut,
    
), {Value = CoreTemp.Value + Target -- or whatever property determines the temperature}):Play()
end)

Yes, but I want the value to increase endlessly, not only to a certain value…

Then you set the repeatcount to -1 for the TweenInfo.

local TweenService = game:GetService("TweenService")

local Speed = 25 -- Default speed, you can set this to whatever you want.
local Addition = 10 -- This is the target temperature for the core
local CoreTemp = -- definition here
local Power = -- definition here

Power.Changed:Connect(function()
local Formula -- some kind of formula to determine the speed of the tween

TweenService:Create(CoreTemp, TweenInfo.new(
    Formula,                        --Speed determined by the math formula
    Enum.EasingStyle.Sine,          --set this as whatever you want
    Enum.EasingDirection.InOut,
    -1
    
), {Value = CoreTemp.Value + Target -- or whatever property determines the temperature}):Play()
end)

yeah but that would create a lot of tweens and most likely break it, right?

No, it wont. Other tweens will cancel out.

I already have something like this and I would rather use that…
image
The add value is basically a value that determines by how much the core temp increases and the wait value decides how quickly. The script is just the handler

I am already using the add value but I really want to use the wait value

Well yeah, you can just not use TweenService if you’re okay with it not being smooth.

I don’t want it to be smooth because the screen uses math.floor anyway

Then just add to the value every few seconds.

Yes but what if I activate cooling?

Then you decrease the value???

that would just slow down the heating process, I want it to actually cool

Then decrease the temperature???