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

Why is GetPropertyChangedSignal not firing?

local Humanoid = require(game.ReplicatedStorage.Compiler.Humanoid)
local Health = require(game.ReplicatedStorage.Compiler.Humanoid.HealthModule)
local DeathHP = 5

game.Players.PlayerAdded:Connect(function(player)
    local Folder = Instance.new("Folder")
    Folder.Parent = player
    Folder.Name = "CustomHumanoid"
    
    local Objects = game.ReplicatedStorage.Compiler.Objects:GetChildren()
    for _,v in pairs(Objects) do
        v:Clone().Parent = Folder 
    end
    
    wait(3)
    Humanoid:SetHealthOnJoin(player) -- module function
    
    Folder:FindFirstChild("Health"):GetPropertyChangedSignal("Value"):Connect(function(property)
		print("property changed")
        if property <= DeathHP then
            print('Death initiated')
            local Messages = {
               -- death messages
            }
            Health:OnDeath(player,Messages) -- other module function
        end
    end)
end)

Why does GetPropertyChangedSignal give up on me whenever I change the health value to under 5 (DeathHP), no prints or anything

Health is an IntValue that I inserted via the for loop so I don't get what's happening here.

1 answer

The default parameter of :GetPropertyChangedSignal() is the property that was changed (string). So, it's not the new value of the property that was changed.

This means that in line 20, you tried to compare a string with a number which causes an error in the script, so the script stops running. To fix this, simply change line 20 to if Folder.Health.Value <= DeathHP then.

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