I’m practicing scripting and created a scenario where you have to collect 4 items to open a door. I would like to get the textLabel to update to show how many items have been collected (“1/4 Collected”, “2/4 Collected”, etc.). I have a value stored in replicated storage and it increases when items are collected. I am using GetPropertySignalChanged in the TextLabel script but it is not updating when the value changes. Anyone have insight into why this isnt working?
local text = script.Parent
local eCollected = game.ReplicatedStorage.eCollected
text.Text = eCollected.Value.."/4 Collected!"
eCollected:GetPropertyChangedSignal("Value"):Connect(function()
text.Text = eCollected.Value.."/4 Collected!"
end)
Are you using a local script when checking for updates? Because I tested this script and it seems to work fine for me
(Nevermind it works fine with a local script too, is your int value actually updating?)
I am collecting them through touched events in a server script. Here is the code for collecting the items and opening the door.
local button = game.Workspace.button.ClickDetector
local door = game.Workspace.door
local e1 = game.Workspace.Evidence.e1
local e2 = game.Workspace.Evidence.e2
local e3 = game.workspace.Evidence.e3
local e4 = game.Workspace.Evidence.e4
local Evidence = game.Workspace.Evidence
local eCollected = game.ReplicatedStorage.eCollected.Value
local openSound = game.Workspace.door_open
local buzzer = game.Workspace["Britain's Got Talent - Buzzer"]
local collected = game.Workspace["Coin Collect 2 - SFX"]
--Evidence Collection (increase eCollected value and destroy part)
for i, child in pairs(Evidence:GetChildren()) do
if child:IsA("BasePart") then
child.Touched:Connect(function()
eCollected = eCollected + 1
child:Destroy()
print(eCollected.."/4 Collected")
collected:Play()
end)
end
end
--Door function (eCollected must = 4)
local function openDoor()
if eCollected >= 4 and door.Transparency == 0 then
door.Transparency = 1
door.CanCollide = false
openSound:Play()
elseif eCollected ~=4 and door.Transparency ~=1 then
buzzer:Play()
end
end
button.MouseClick:Connect(openDoor)