#How to check if Attribute is changed

1 messages · Page 1 of 1 (latest)

worldly thunder
#

ok so basically it works when i set it to true when the players join but when they key the key and the value is set to true then it doesnt work when I touch the base ``` local key = script.Parent
local door = workspace.Door
local base = door.Base

game.Players.PlayerAdded:Connect(function(player)
player:SetAttribute("HasKey", false)
end)

key.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then

    player:SetAttribute("HasKey", true)
    print(player.Name .. " got the key!")
    key:Destroy()  
end

end)

base.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player:GetAttributeChangedSignal("HasKey") == true then
print(player.Name .. " has the key. Destroying base...")
base:Destroy()
else
print(player.Name .. " doesn't have the key.")
end
end
end)

worldly thunder
#
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        player.AttributeChanged:Connect(function(HasKey)
            if HasKey == true then
                base:Destroy()
            end
            
        end)
            
        
    end
end)``` is it suppose to be like this
#

cuz if it is, then its not working

#

@fiery quest

proud otter
#

read bro xd

fiery quest
#

Read the code and no this is not what you want