Hi I just wanted someone to explain how the game knows to delete Yellow if it’s touching YellowPart, but to not delete lets just say red if it’s touching YellowPart using this code.
local Yellow = game.Workspace.Yellow
local YellowPart = game.Workspace.YellowPart
game.Workspace.Yellow.Touched:Connect(function(partTouching)
if YellowPart == partTouching then
YellowPart:Destroy()
end
end)
You have told it to do so. The == operator compares both of its operands and returns true if they are the same otherwise false. So it passes the conditional test and proceeds with destroying.
The argument in the parenthesis represents the instance that fired the event. In this case the event is Touched and the instance that fired the event is partTouching, so partTouching represents the part that touched Yellow.
Now, you’re saying that if YellowPart is the part that touched yellow, then destroy it.