Read the code and you’ll understand what I’m trying to do, I don’t know how to describe it.
if (not hit:FindFirstChild("Attachment")) == p:FindFirstChild("LineForce").Attachment1 then
--le code
end
Read the code and you’ll understand what I’m trying to do, I don’t know how to describe it.
if (not hit:FindFirstChild("Attachment")) == p:FindFirstChild("LineForce").Attachment1 then
--le code
end
When you say
It is making it say if false == p:FindFirstChild("LineForce").Attachment1 then
I am confused on what you are trying to do here. A little explanation would help!
Basically, I need to find if the attachment inside hit is the same as the attachment inside the lineforce inside p, but if the lineforce doesn’t exist, it errors.
Are you trying to check if both conditions are true?
If you are then, you can use the code below:
We use and
operator to check if both conditions are true or false.
if not hit:FindFirstChild("Attachment") and p:FindFirstChild("LineForce").Attachment1 then
--le code
end
If i understand, is this what you are trying to do?
if (not hit:FindFirstChild("Attachment")) == p:FindFirstChild("LineForce").Attachment1 and p:FindFirstChild("LineForce").Attachment1 ~= nil then
--le code
end
local Attachment = hit:FindFirstChild("Attachment")
local LineForce = p:FindFirstChild("LineForce")
if Attachment and LineForce and LineForce.Attachment1 == Attachment then -- Check if Attachment 1 is equal to Attachment
-- same attachment
else
if Attachment and LineForce and LineForce.Attachment1 ~= Attachment then
-- different attachment
end
end
charsdrrrrrrrrrrrrrrrsss
Are you trying to check if both Instances are the same class?
Or a property inside them?
I should probably give the full code, I didn’t think it would really matter but
if (not hit:FindFirstChild("Attachment")) == p:FindFirstChild("LineForce").Attachment1 then
line = Instance.new("LineForce", p)
att0 = Instance.new("Attachment", p)
att1 = Instance.new("Attachment", hit)
att0.Name = "Attachment0"
att1.Name = "Attachment1"
line.InverseSquareLaw = true
line.ReactionForceEnabled = true
line.ApplyAtCenterOfMass = true
line.Magnitude = p:GetMass()
line.Attachment0 = att0
line.Attachment1 = att1
end
end)
No, if the attachment inside hit is the very same attachment that is the Attachment1 of the lineforce.
The code I wrote checks if they are the same attachment.
You can then just do:
if hit:FindFirstChild("Attachment") == p:FindFirstChild("LineForce").Attachment1 then
--le code
end
The issue though is that it creates the attachments and lineforces outside of the if statement, which means it only has the capacity for one force
So we would need to run a for loop and check all of them?
The only change I see is the not
removed, which will continuously create lineforces and then cause everything to come together with so much force that it will literally explode.
This is how it went the first time, so I added this.
No, because whenever p
is touched, it already does that. p
will be touched tons of times because the lineforces will be pulling them together.
I am confused because you said there are going to be multiple LineForces and Attachments?
That would be the case if I removed the if statement. It would cause the lineforces to constantly be created, thus applying so much force that the two connected objects will explode, sending them away from each other at high speeds.
What if you delete the old LineForce?
I’ll try that, I’ll report the results to you in a few hours 'cause I gotta go.
Nvm, plans changed