:GetAttributeChangedSignal() Triggering but script says value is still false

The script.

local Remotes = script.Parent:WaitForChild("Remotes")
local CharHealthStats = script.Parent

local Lighting = game:GetService("Lighting")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--Bleeding
local Stats = CharHealthStats.Generic.Stats
local BleedingValue = CharHealthStats.Generic.Stats:GetAttribute("Bleeding")
local BloodLevel = CharHealthStats.Generic.Stats:GetAttribute("BloodLevel")
local BleedType = CharHealthStats.Generic.Stats:GetAttribute("BloodType")

local BleedTime = {
1.55,
0.55,
0.33
}

local BloodLoss = {
1,
2,
3
}

Stats:GetAttributeChangedSignal("Bleeding"):Connect(function()
	print("Changed!")
	warn(BleedingValue)
	if BleedingValue == true then
		warn("Value is true, returning values", BloodLevel, BleedingValue)
		warn("Checking Severity", BleedType)
		
		if BleedType == "Mild" then -- MILD
			
			warn("put something here later!")
			
		elseif BleedType == "Normal" then -- NORMAL
			
			warn("put something here later!")
			
		elseif BleedType == "Severe" then -- SEVERE
			
			warn("put something here later!")
			
		end
		
		
end
end)

image
image

Think u need to run :GetAttribute() again

1 Like

This is because variables essentially create a copy of the object when it’s called. So, if your variable is an attribute of 1, reading it when it’s changed will still return 1. You will need to make a variable called ChangedBleeding in your function that gets the e attribute again.

2 Likes

It’s probably because it’s waiting until the next frame to actually change the value in the engine. You could try connecting to a different event that runs every frame, like RunService.Heartbeat which would probably work.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.