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.

01local Slot1 = script.Parent.Slot1
02local Slot2 = script.Parent.Slot2
03 
04script.Parent.Slot1.Value.Changed:Connect(function()
05    print("Changed")
06if Slot1.Value.Value == 1 then
07        Slot1.Image = "http://www.roblox.com/asset/?id=183584653"
08else
09        Slot1.Image = "http://www.roblox.com/asset/?id=1884857885"
10end
11end)
12script.Parent.Slot2.Value.Changed:Connect(function()
13    print("Changed")
14    if Slot2.Value.Value == 1 then
15        Slot2.Image = "http://www.roblox.com/asset/?id=183584653"
16 
17else
19    end
20end)

2 answers

Log in to vote
1
Answered by 4 years ago

U gotta use GetPropertyChangedSignal

01local Slot1 = script.Parent.Slot1
02local Slot2 = script.Parent.Slot2
03 
04Slot1:GetPropertyChangedSignal("Value"):Connect(function()
05print("Changed")
06if Slot1.Value.Value == 1 then
07        Slot1.Image = "http://www.roblox.com/asset/?id=183584653"
08else
09        Slot1.Image = "http://www.roblox.com/asset/?id=1884857885"
10end
11end)
12Slot2:GetPropertyChangedSignal("Value"):Connect(function()
13    print("Changed")
14    if Slot2.Value.Value == 1 then
15        Slot2.Image = "http://www.roblox.com/asset/?id=183584653"
16 
17else
19    end
20end)
Ad
Log in to vote
0
Answered by 4 years ago
01local Slot1 = script.Parent.Slot1
02local Slot2 = script.Parent.Slot2
03 
04script.Parent.Slot1.Changed:Connect(function(prop)
05if prop == "Value" then
06        print("Changed")
07    if Slot1.Value.Value == 1 then
08            Slot1.Image = "http://www.roblox.com/asset/?id=183584653"
09    else
10            Slot1.Image = "http://www.roblox.com/asset/?id=1884857885"
11    end
12end
13end)
14script.Parent.Slot2.Changed:Connect(function(prop)
15if prop == "Value" then
View all 24 lines...

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