I am trying to make an attribute when set to true, the part removes when a player touches it.
but if I turn it on, it actually works, when I step on it, it is deleted.
but if I turn it off, and then on it does not work.
i tried this code:
local Part = script.Parent
local DOT = Part:GetAttribute("DisappearOnTouch")
while true do
if DOT == true then
script.Parent.Touched:Connect(function()
script.Parent:Destroy()
end)
end
end
Don’t do a loop for this. Instead, check if DOT is true when the part is touched.
local Part = script.Parent
script.Parent.Touched:Connect(function()
if Part:GetAttribute("DisappearOnTouch") then
script.Parent:Destroy()
end
end)
To answer the question as to why your code wouldn’t work anyway, you’re setting the DOT variable to the attributes value. Meaning it won’t change if the attribute changes.
I’m not really familiar with attributes, could you try just adding the DisappearOnTouch attribute without any value like false? That may be interfering with :GetAttribute though this may be very wrong as :GetAttribute only listens for the name and not the attribute’s value.
No, like, you have the name of the attribute, leave the other part blank. I’m banned from Roblox as of now so I can’t show you what I mean.
In this image, leave the space where you would put “75”, “32”, etc. blank. And try again.