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

Script when a value is in a range of numbers? [closed]

Asked by
jakeovi -1
4 years ago
workspace.TimeSurived:GetPropertyChangedSignal("Value"):Connect(function()
    if workspace.TimeSurived.Value 40-60 then
--code here
end 
end)
0
Do "if game.Workspace.TimeSurvived.Value >= 40 or game.Workspace.TimeSurvived.Value <= 60 then" Spjureeedd 385 — 4y

Closed as Non-Descriptive by JesseSong, jediplocoon, marine5575, zblox164, Utter_Incompetence, and killerbrenden

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
srimmbow 241 Moderation Voter
4 years ago

"and" runs the code only if both requirements are met. So, it's checking if the value is greater than or equal to 40 AND is less than or equal to 60.

workspace.TimeSurived:GetPropertyChangedSignal("Value"):Connect(function()
    if workspace.TimeSurived.Value >= 40 and  workspace.TimeSurived.Value <= 60 then
        --code here
    end 
end)
Ad
Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
4 years ago
workspace.TimeSurived:GetPropertyChangedSignal("Value"):Connect(function()
    local val = workspace.TimeSurived.Value
    if val > 40 and val < 60 then
        -- code here
    end 
end)