Hello yall, Immebest here, your scripting newbie. Today I was attempting to script a light bulb which basically changes material from plastic to neon when the tempreture or value in this case is above 7500 and the light goes out when its below 7500.
Basically, what I want is:
The bulb should go on and start blinking by changing materials when the tempreture is above 7500.
and stop blinking when the temp is below 7500.
Here is the script I tried, any help would be appriciated.
local Startup = game.Workspace.Values.Temp
function ChangeState()
repeat
script.Parent.Material = Enum.Material.SmoothPlastic
wait(0.5)
script.Parent.Material = Enum.Material.Neon
wait(0.5)
script.Parent.Material = Enum.Material.SmoothPlastic
until Startup.Value < 7500
end
if Startup.Value >= 7500 then
ChangeState()
end
Startup.Changed:connect(function(NewVal)
if NewVal == true then
ChangeState()
end
end)
Thanks.
Edit 1: Startup(local) is the tempreture which it must be above to work. I was to lazy to change the start up local to another name like idk “tempreture”.
Edit 2: I am a noob at scripting, please try to explain my flaws as simple as possible. I may not understand you.
For what I understood, “Startup” is an IntValue, right?
You cant compare a int value with “true”, that’s why the script will never enter this scope
I also don’t see where you’re changing the temperature value. I assume it should be in other script, right?
Correct, sorry for the confusion this script was taken from a start up script that I made but I was too lazy to chance the start up as the local name.
So basically,
startup is the tempreture value.
and also I would like to add that, I just took the script from another devforum page but didnt learnt how it actually works so there is some obvious flaws that I may not understand, so I am a newbie so please try to explain this as plain as possible as you can.
you are checking if the variable “NewVal” (a integer number) is equal to “true” (a boolean → Not a number), which doesn’t make sense. Instead, you need to compare it like this:
if NewVal >= 7500 then
that means: “Is NewVal greater or equal to 7500?”