Rhino123
(Rhino123)
July 29, 2022, 5:36pm
#1
I have this piece of code:
local CheckOwner = mtarg.Owner
if not CheckOwner or CheckOwner.Value == player.Name then
When it runs, this error comes up.
Does putting ‘if not’ not do what I think it does, check if the thing does not exist? Or does it have something to do with ContextActionService?
Thanks for any help in advance
ayoub50
(Ayoub)
July 29, 2022, 5:39pm
#2
is that what you meant?
if not CheckOwner or not
since its checking that CheckOwner doesn’t exist it can’t assign a value for it.
1 Like
Rhino123
(Rhino123)
July 29, 2022, 5:41pm
#3
The script checks if either…
The CheckOwner object does not exist
or
the CheckOwner objects value is equal to the player’s name
gertkeno
(Gert)
July 29, 2022, 5:43pm
#4
The error is not related to the if expression. mtarg
(Workspace.Bluesteel Axe) does not have a property or child named Owner
ayoub50
(Ayoub)
July 29, 2022, 5:43pm
#5
instead of local CheckOwner = mtarg.Owner
change it to local CheckOwner = mtarg:FindFirstChild(“Owner”)
2 Likes
Rhino123
(Rhino123)
July 29, 2022, 5:45pm
#6
Thanks… I thought I had tried that already but it worked now
1 Like
gertkeno
(Gert)
July 29, 2022, 5:49pm
#7
if not CheckOwner then
-- is equivalent to
if CheckOwner == nil then
The reason the or CheckOwner.Value
doesn’t error is because if statements are read left to right, if the left side of or
is true then it will skip the right part. not
does nothing special to check existance.