Im making a cooking game, and the whole idea is that the food items all have a cooked attribute that changes depends on the temperature of the food, It gets cooked when it is below the MaxTemp and Above the MinTemp for cooking. But for some reason whenever i set the CurrentTemp attribute to a different temp the AttributeChangedSignal function does not fire.
Heres the code:
local collectionservice = game.CollectionService
collectionservice:GetInstanceAddedSignal("food"):Connect(function(instance:Part)
instance:GetAttributeChangedSignal("CurrentTemp"):Connect(function()
if instance:GetAttribute("CurrentTemp") <= instance:GetAttribute("MaxTemp") and instance:GetAttribute("CurrentTemp") >= instance:GetAttribute("MinTemp") then
instance:SetAttribute("cooked", true)
end
end)
end)
Make sure that an attribute is set for the instance… Or in setting another attribute value by using SetAttribute(), else, try checking if the GetInstanceAddedSignal gets fired or printed at least, then debug your way out of there.
The instance you’re refering to probably already exists ingame and therefore the GetInstanceAddedSignal never fires resulting to GetAttributeChangedSignal not getting binded
i clone the food from serverstorage and im trying to change the attributes on the clone, the script does know when the food is added to the workspace, but the code after the first part(collectionservice:GetInstanceAddedSignal("food"):Connect(function(instance:Part)) doesnt seem to work