Search code examples
luaroblox

Roblox if value change print 1 else print 2


I don't really know how to do it, so all I could find is something like this for example:

Local abc = script.parent

abc.Changed:Connect(function()
Print(“1”)

end)
Else 
Print(“2”)

Solution

  • Your best bet would be to store the old value and then check when you need to do if the value is changed and print accordingly. Here's an example.

    local abc = script.Parent.Value
    
    --- When you need to check if it's changed
    
    if script.Parent.Value ~= abc then
        print("Changed")
    else
        print("Same")
    end