Roblox Studio Check If Value Changed Lower

Hello, I want to make a script What Checks and Prints Something if the Value got Lower. Can you please tell me how so I can make this. It’s a very small Topic but I couldn’t find something.

2 Likes

U can do YourValue.Changed:Connect(function() end)

I know but it doesn’t check if the Value got lower. I want to only check it if the Value got lower.

You can make a place holder for the lowest value
if PlaceHolder.Value > YourValue then

1 Like

No. I want to check If the Value Changed Lower (-)

Do you mean the value got less? Like this 15 to 14?

1 Like

Yes That is what I mean. Do you know something about that?

@111122233333 did this in his previous post

if PlaceHolder.Value > YourValue then
– your code you want to run when the value is decreased
end)

If the changed value got less that is what I want to know

You would need to use the Changed event and make a placeholder value that would change when the value changes.

For example

local PlaceHolderValue = IntValue.Value -- sets placeholder value

IntValue.Changed:Connect(function()
    if PlaceHolderValue > IntValue.Value then -- checks to see if it decreased
        -- code here
        PlaceHolderValue = IntValue.Value -- sets PlaceHolderValue to the new value
    end
end)

This is pretty much what has already been said, not sure if you quite understood what people were trying to say. Also if you only want the placeholder value to change when it gets lower keep it in the if statement, otherwise keep it out of the if statement.

3 Likes

Aren’t you supposed to update the PlaceHolderValue regardless of the if statement?

depends if you only want the placeholder value to change when it decreases, that is why I added this at the end of my reply.

How do you format the code like this with the font and colored text? Sorry I am new to the devforums :sweat_smile:

You use three ` (ticks) before and after your code.

local value

you need to time ` three times and to give it a color type lua at the start

grafik

print("like this")
1 Like

Unrelated but showing “special symbols” easily can be done using the backslash (\) before the “special symbol”. Backslash itself is a “special symbol” so to show it you will need two backslashes (\\) => (\) and so on.

```lua
print(“Like this.”)
```

“This is pretty much what has already been said, not sure if you quite understood what people were trying to say.”

Not really.