Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script doesnt detect changed values?

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

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)

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()

5 comments

0

I suggest you add an explanation.

0

i suggest you read the 4 lines i added

0

There is no comments whatsoever. I would accept comments or an explanation for a good answer.

0

It still dossent work. it dosen't even print changed

0

@krist use getpropchanged @davy not even an idiot doesnt know what "if prop == value" is

This discussion is preserved as it was. New answers, comments, and votes are closed.