Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

What did I do wrong?? Please help (Involved changing events)

Asked by 2 years ago

Im creating a core, that activates a ton of effects once the temperature reaches 1600 degrees, and heres what I have

wait(1) 
local act = _G.actvalue -- The global value
local inuse = false -- This is neccecary only for the script to not break 

function alarmchange(button)
    if not inuse then
        inuse = true
        if act.Value == "Inactive" then
            act.Value = button.Name
            button.Text = button.Name.." Alert Enabled"
            wait(2)
            button.Text = "Disable "..button.Name.." Alert"
        elseif act.Value == button.Name then
            act.Value = "Inactive"
            button.Text = button.Name.." Alert Disabled"
            wait(2)
            button.Text = "Enable "..button.Name.." Alert"
        else
            button.Text = "Error: "..act.Value.." Alert Enabled"
            wait(2)
            button.Text = "Enable "..button.Name.." Alert"
        end
        inuse = false
    end
end

function effectactivator()
    if game.Workspace.Coretemps.Temp.Current.Value > 1600 then
    alarmchange(script.Parent.Red)
end
if game.Workspace.Coretemps.Temp.Current.Value < 1600 then
    alarmchange(script.Parent.Inactive)
end
end

game.Workspace.Coretemps.Temp.Current.Changed:Connect(effectactivator)
game.Workspace.Coretemps.Temp.Current.Changed:Connect(alarmchange)

Once the core reaches 1600 degrees, it changes the global value to "Red" which is supposed to activate the effects, but instead the effects only activate if I set the temp above 1600 before starting the server?

Not sure what I did wrong, and I know im using a global value, but I don't want to change anything that isn't directly causing things to not work.

Thanks! -Jonathox

Edit- Nobody has given me a working solution yet =[

0
what is wrong with using a global value? justoboy13 153 — 2y
0
Did you mean to put `>= 1600 in your "effectactivator()" function? That's a very simple fix if you want it to go off at exactly 1600 and not only when it's above. MooMooThalahlah 421 — 2y
0
No, I want it to continue going off at all numbers above 1600 Jonathox 4 — 2y

1 answer

Log in to vote
0
Answered by
Fifkee 1956 Administrator Moderation Voter
2 years ago

Put the conditional statement in a loop. You might have to change your stuff though. The conditional statement only works once, and it wont reactivate itself after the script runs by it. (unless you meme'd it around and put it in a loop or some other stuff like that)

0
Thanks! How would i write that with the conditional statement i have? Jonathox 4 — 2y
Ad

Answer this question