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

Script doesnt detect changed values?

Asked by 4 years ago

i am trying to make inventory, but the script doesn't detect changed values these values are in the buttons in gui and i am using local script.

local Slot1 = script.Parent.Slot1
local Slot2 = script.Parent.Slot2

script.Parent.Slot1.Value.Changed:Connect(function()
    print("Changed")
if Slot1.Value.Value == 1 then
        Slot1.Image = "http://www.roblox.com/asset/?id=183584653"
else
        Slot1.Image = "http://www.roblox.com/asset/?id=1884857885"
end
end)
script.Parent.Slot2.Value.Changed:Connect(function()
    print("Changed")
    if Slot2.Value.Value == 1 then
        Slot2.Image = "http://www.roblox.com/asset/?id=183584653"

else
    Slot2.Image = "http://www.roblox.com/asset/?id=1884857885"
    end
end)

2 answers

Log in to vote
1
Answered by 4 years ago

U gotta use GetPropertyChangedSignal

local Slot1 = script.Parent.Slot1
local Slot2 = script.Parent.Slot2

Slot1:GetPropertyChangedSignal("Value"):Connect(function()
print("Changed")
if Slot1.Value.Value == 1 then
        Slot1.Image = "http://www.roblox.com/asset/?id=183584653"
else
        Slot1.Image = "http://www.roblox.com/asset/?id=1884857885"
end
end)
Slot2:GetPropertyChangedSignal("Value"):Connect(function()
    print("Changed")
    if Slot2.Value.Value == 1 then
        Slot2.Image = "http://www.roblox.com/asset/?id=183584653"

else
    Slot2.Image = "http://www.roblox.com/asset/?id=1884857885"
    end
end)

Ad
Log in to vote
0
Answered by 4 years ago
local Slot1 = script.Parent.Slot1
local Slot2 = script.Parent.Slot2

script.Parent.Slot1.Changed:Connect(function(prop)
if prop == "Value" then
        print("Changed")
    if Slot1.Value.Value == 1 then
            Slot1.Image = "http://www.roblox.com/asset/?id=183584653"
    else
            Slot1.Image = "http://www.roblox.com/asset/?id=1884857885"
    end
end
end)
script.Parent.Slot2.Changed:Connect(function(prop)
if prop == "Value" then
        print("Changed")
        if Slot2.Value.Value == 1 then
            Slot2.Image = "http://www.roblox.com/asset/?id=183584653"

    else
        Slot2.Image = "http://www.roblox.com/asset/?id=1884857885"
        end
    end
end)

Or, you can use :GetPropertyChangedSignal()

0
I suggest you add an explanation. Dovydas1118 1495 — 4y
0
i suggest you read the 4 lines i added Dan_PanMan 227 — 4y
0
There is no comments whatsoever. I would accept comments or an explanation for a good answer. Dovydas1118 1495 — 4y
0
It still dossent work. it dosen't even print changed kristupas12344 26 — 4y
0
@krist use getpropchanged @davy not even an idiot doesnt know what "if prop == value" is Dan_PanMan 227 — 4y

Answer this question