The question is in the title.
Thanks for help!
The question is in the title.
Thanks for help!
try this (might not work)
local bool = (bool location)
if bool == true then
(code)
else
(code)
This doesn’t work. I tried this a few minutes ago.
Yeah, then I do not know sorry
Did it error? This should work.
Oh wait, it does work. I did something other wrong. Thanks for help
Just to note, another way it can be done is
local bool = (bool location or a bool value you set)
if bool then
--Code if true
else
--Code if false
end
--Alternatively you can use not to check if the value is false or not
if not bool then --This checks if bool is false
--Code
else --If not false then do what's after the else
--Code
end
Both methods work fine so use what I or @Stickpuppet mentioned. Keep in mind my method will only work if you are only checking a single bool value and no other conditions
Try This:
if v:GetAttribute("Killable") == true then
end
Hi.
I’m guessing I’m a little late but to check if an attribute is true, you could do this:
local Attribute = InstanceOfChoice:GetAttribute("AttributeName")
if Attribute and Attribute == true then
-- The attribute is true
else
-- The attribute is false
end
Hope this helps, even though it’s a year late.
Thanks for still taking your time to reply to this post, but I already figured out how to do that.
Thanks for the answer, helped me a lot with an attribute boolean.
This is what I got from it. Anyway have a good rest of your day/night.
local detector = script.Parent.ClickDetector
detector.MouseClick:Connect(function(player)
if detector:GetAttribute("Boolean") == false then
detector:SetAttribute("Boolean", true)
-- more code here
end
end)
Hey, replying to clarify something. Apparently :GetAttribute() == true can apply to two things: not only if the attribute is set to true, but also if it exists, and it seems like Studio always considers the latter. A probably stupid, but nevertheless reliable alternative to this is changing it to any other value type and checking for the desired one.