I want to change the last slot with slot1 and slot2 value. I dont want to use while wait() do because I want something more clean I tried to use :GetPropertyChangedSignal but is not working.
This is the board. Before I tried to use while wait() do it works but I want to use :GetPropertyChangedSignal on it
local Board = script.Parent
local Slots = Board.Slots
local Buttons = Board.Buttons
local slot1 = Slots.Slot1
local slot2 = Slots.Slot2
local resultSlot = Slots.ResultSlot
local slot1Add = Buttons.Slot1Add
local slot1Remove = Buttons.Slot1Remove
local slot2Add = Buttons.Slot2Add
local slot2Remove = Buttons.Slot2Remove
local mathSlot = Buttons.MathSlot
local additionButton = Buttons.AdditionButton
local subtractionButton = Buttons.SubtractionButton
local divisionButton = Buttons.DivisionButton
local multiplicationButton = Buttons.MultiplicationButton
local slot1Value = slot1.Slot1Value
local slot2Value = slot2.Slot2Value
local resultValue = resultSlot.ResultSlotValue
local mathValue = mathSlot.SlotValue
local slot1Text = slot1.SurfaceGui.TextLabel
local slot2Text = slot2.SurfaceGui.TextLabel
local resultText = resultSlot.SurfaceGui.TextLabel
local mathText = mathSlot.SurfaceGui.TextLabel
--------------- Adding/Removing --------------------
slot1Add.ClickDetector.MouseClick:Connect(function()
slot1Value.Value = slot1.Slot1Value.Value + 1
slot1Text.Text = slot1Value.Value
end)
slot1Remove.ClickDetector.MouseClick:Connect(function()
slot1Value.Value = slot1.Slot1Value.Value - 1
slot1Text.Text = slot1Value.Value
end)
slot2Add.ClickDetector.MouseClick:Connect(function()
slot2Value.Value = slot2.Slot2Value.Value + 1
slot2Text.Text = slot2Value.Value
end)
slot2Remove.ClickDetector.MouseClick:Connect(function()
slot2Value.Value = slot2.Slot2Value.Value - 1
slot2Text.Text = slot2Value.Value
end)
additionButton.ClickDetector.MouseClick:Connect(function()
mathValue.Value = 0
mathText.Text = "+"
end)
subtractionButton.ClickDetector.MouseClick:Connect(function()
mathValue.Value = 1
mathText.Text = "-"
end)
divisionButton.ClickDetector.MouseClick:Connect(function()
mathValue.Value = 2
mathText.Text = ":"
end)
multiplicationButton.ClickDetector.MouseClick:Connect(function()
mathValue.Value = 3
mathText.Text = "X"
end)
----------------------------------------------------------
resultValue:GetPropertyChangedSignal("Value"):Connect(function(change)
resultText.Text = resultValue.Value
if mathValue.Value == 0 then
resultValue.Value = slot1Value.Value + slot2Value.Value
elseif mathValue.Value == 1 then
resultValue.Value = slot1Value.Value - slot2Value.Value
elseif mathValue.Value == 2 then
resultValue.Value = slot1Value.Value / slot2Value.Value
elseif mathValue.Value == 3 then
resultValue.Value = slot1Value.Value * slot2Value.Value
end
change:Desconnect()
end)
When I looked at your code once again, I can’t see value of resultValue changing anywhere in the code, that must be the reason why :GetPropertyChangedSignal for Value never fires.
You are changing value of resultValue inside the GetPropertyChangedSignal function which never fires since the value is never changed!
Using the mathValue, you can find the result of the addition/subtraction/multiplication/division of the two numbers and change the value of resultValue using a script, and that will fire GetPropertyChangedSignal for resultValue!
When setting these values, use their symbols to carry out the arithmetic operations on the two numbers in slot1 and slot2 and when you have the result of the operation, change the value of resultValue. That will do it.