Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make effects happen once a numbervalue gets above 1600?

Asked by 6 years ago
if game.Workspace.Coretemps.Temp.Current.Value > 1600 then
    script.Parent.Decal.Transparency = 0
end
if game.Workspace.Coretemps.Temp.Current.Value < 1600 then
    script.Parent.Decal.Transparency = 1
    end

Im making a core that activated certain effects once the core gets above 1600 degrees. I made this script to make a decal appear, but when I test the game out, for some of the corridors, this works, but sometimes it doesn't???

Keep in mind that I have about 15 of these decals with this same script, and sometimes they all work sometimes they dont..? Cant understand why???

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Put it in a changed event.

game.Workspace.CoreTemps.Temp.Changed:Connect(function(property)
    if game.Workspace.CoreTemps.Temp.Value > 1600 then
        script.Parent.Decal.Transparency = 0
    else
        script.Parent.Decal.Transparency = 1
    end
end)

To edit it not working and so it doesn't have to change, try this

while wait() do
    if game.Workspace.CoreTemps.Temp.Value > 1600 then
        script.Parent.Decal.Transparency = 0
    else
        script.Parent.Decal.Transparency = 1
    end
end
0
A changed event fires when a property changes value. (E.g.) The name of something, it's parent property, and in your case value property. I doubt it'd change name or parent property or archivable property, so it's safe to assume the Value property is changing. User#19524 175 — 6y
0
I tried using that script, and now none of them are working?? I set the temperature to automatically start as 2000 so it should display the decal. Jonathox 4 — 6y
0
Because the property has to change. User#19524 175 — 6y
0
I'll edit the script. User#19524 175 — 6y
View all comments (3 more)
0
Oh...so if i set the core temperature to increase gradually, then once it hits above 1600, it will automatically work? I get it! So, im writing it right now, but how would I make a script for the temp to increase gradually from the click of a button?? Thanks so much for the help! Jonathox 4 — 6y
0
I created a button that adds 500 degrees and it worked but it shot the temp up to 2000 and the decals were supposed to work at 1600 with the script you gave me? Jonathox 4 — 6y
0
Your button adds 500 degrees. Of course if you're at 1500 and click it, it's going to go to 2000+ change the decal. There's nothing in the script limiting it to max out at 2000, if that's what you're asking. Maxwell_Edison 105 — 6y
Ad

Answer this question