Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

These two values are the same but don't work in a if statement?

if playerMouse.Target.Parent.Owner.Value == player.Team then

When I print either of these values they both come out as blue. The Owner.Value is a string value within a model. An if statement doesn't come out true for some reason. I have printed and know that its doing

if blue == blue then

What is wrong with this?

2 comments

0

I think mouse.Target is a string and a string dosent have a b\parent

1

mouse.Target is the part the mouse is on.

1 answer

✓ Accepted answer

I don't have much experience with Teams, but what I believe is happening is you're attempting to compare a string with an object. To fix this, try comparing the Value to Team.Name instead of Team.

When printing an object in roblox, the output lists its name, but the reference to the object is not actually the name. For instance, consider a part in the workspace named Part as well as a string variable Part:

local part = workspace.Part
local partString = "Part"

print(part, part.Name, partString)
print(part == partString)
print (part.Name == partString)

The first print statement would print (Part, Part, Part). However, the second statement would print out false, as it's not comparing the two directly. The third should work.

1 comment

0

Oh daummmm adding .Name worked. I didn't know .Name was part of that.. Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.