Issues with making a lever which only works during the ranges of 7.5k to 10k tempretures. That cools the reactor down

Hello yall, I am that one newbie who tried to script with literally 0.001% knowladge. Basically, I am trying to make a lever that cools the reactor down when its active. The things I want are:

1- This Lever should only work in the tempreture ranges of 7500 to 10000.
2- This should cool the reactor down until the temp normalises back to 7500.
3 - Said lever should shut off again when the temp is back at 7500.

Additional Info:

  • Lever State

    This is a readable value which provides whether the lever
    is currently pulled or not.

    When this value is true, this means the lever’s state is ON.
    When it is false, this means the lever’s state is OFF’.

  • Functional

    This is a changeable value that controls whether or not the
    lever is functional.

    When this value is true, you will not be able to pull the lever.
    When it is false, the lever will become pullable again.

  • Reset On Change

    This is a changeable value that controls whether or not the
    lever will reset to OFF when pulled and functional is false.

    Additionally the lever will only reset to the OFF state when
    it is currently set to the ON state.

    When this value is true, the lever will reset to the OFF state.
    When it is false, the lever will stay in It’s current state.

and my scripts are:

local temp = game.Workspace.Values.Temp.Value

	if temp <= 10000 then
		script.Parent.Values.Functional = false
	elseif temp <= 7500 then
	script.Parent.Values. Functional = true
end

^^^ Prevents the lever from being activated if its not inrange

The other scripts, such as cooling. I have no idea on how to code them and would greatly appriciate if someone did it for me or gaved me a proper idea on what to do.

Cheers.

1 Like

if you need to check when the temperature is fine:

shouldPush = temp >= 7500 and temp <= 10000 -- will be true if its between 7500 and 10000
1 Like

The elseif won’t run since the temp will always be less or = to 10000, so try this

local temp = game.Workspace.Values.Temp.Value

	if temp >= 7501 then
		script.Parent.Values.Functional = false
	elseif temp <= 7500 then
	script.Parent.Values. Functional = true
end
1 Like

I like how your constantly helping me with these ones, although I would appriciate if you could also answer my other issues.

1 Like

doesnt seem to work. maybe I did a little few oopsies. will final check and let you know.

doesnt seem to work, any more ideas?

Try this,

local temp = game.Workspace.Values.Temp.Value

	if temp <= 10000 and temp >= 7501 then
		script.Parent.Values.Functional = false
	elseif temp <= 7500 then
	script.Parent.Values. Functional = true
end

Np, but I am helping you on what I am able to help you on, I am primarily a Modeler on Blender and am not a pro with scripting , if i did know how to help you i would love to but sadly i cant

1 Like

Still doesnt seem to work, I feel like its rather the games fault then your scripts. Although thanks for giving me these scripts i may have needes them for later.

1 Like

Ok so firstly there isn’t an event or something that triggers the script meaning it will only run as the game starts and not again after that I would recommend using the value.Changed event, that would look something like this

local temp = game.Workspace.Values.Temp

temp.Changed:Connect(function()
	if temp.Value >= 7500 and temp.Value <= 10000 then
		script.Parent.Values.Functional.Value = true
	else
		script.Parent.Values.Functional.Value = false
	end
end)

Now the script runs every time the temperature changes and checks if it is between 7500 and 10000

As for the cooling part, you will most likely use a loop to continuously lower the temperature until it is under 7500. You can just use the Functional value, since it automatically changes depending on the temperature, to detect when it’s under 7500 and stop the loop.
Going to leave this part for you to figure out so good luck!

1 Like

Thanks I will try this out soon and for the other part, incase I do fOOF up. I will probably come back for help