Making a temperature system for my core

  1. What do you want to achieve? A working temperature system for the fusion core in my game, with a different added value if there are different power levels, fan levels, or coolant levels.

  2. What is the issue? The value does not change. It is an IntValue, for context.

  3. What solutions have you tried so far? Tried looking up answers, but none of them relate to what I need.

Here is the current script I have:

local Temperature = script.Parent.Temperature
LaserLevel = script.Parent.Levels.LaserLevel
while true do
	wait(1)
	if LaserLevel.Value == 100 then
		Temperature.Value = Temperature.Value + 40
	else if LaserLevel.Value == 75 then
			Temperature.Value = Temperature.Value + 30
		else if LaserLevel.Value == 50 then
				Temperature.Value = Temperature.Value + 20
			else if LaserLevel.Value == 25 then
					Temperature.Value = Temperature.Value + 10
				end
			end
		end
	end
end

All help would be grateful! Thank you for helping!

Lasers: Fixed by @paap15
Coolant: In the works
Fans: In the works

1 Like

I believe you need to do

local temperature = script.Parent.Temperature

then do

temperature.Value = temperature.Value + 40

In your version you are just storing the value, in stead you need to store the reference to the intvalue instance.

Also you should only loop though laser descendants once and do all the checks in the single loop.

4 Likes

Iā€™m changing the if loops to check the value of another IntValue for laser levels

2 Likes
for i, v in pairs(Lasers:GetDescendants()) do
		if v.Name == "Laser" then
			if v.Transparency == 1 then
				temperature = temperature + 50
            elseif v.Transparency == 0.75 then
                  ...

			end
		end
	end

This should give the same result

2 Likes