Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Touched's perimeter otherParts not work with if statement that compares perimeter with string?

Asked by 3 years ago
Edited 3 years ago
game.workspace.Sell.sellpart.Touched:Connect(function(otherPart)
    if otherPart == "Food" then
        print("success")
    end
end)

This does not work at all ^. I it so when the part called "Food" touches the Sell.sellpart it becomes detected. When I do:

game.workspace.Sell.sellpart.Touched:Connect(function(otherPart)
    print(otherPart)
end)

It is able to detect parts. And it detects Food when that part touches the sellpart.

I have absolutely no idea what to do.

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

After looking in the toolbox for a tycoon model and finding out how the tycoon's selling system worked, I found out this:

If you type in:

game.workspace.Part1.Touched:Connect(function(Part2)

end)

Then Part1 will look to see if it touched Part2.

So yeah don't do what I did. And also look at successful code first before you post onto a forum. Hopefully, I helped people avoid my own mistakes.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Lol, WHO asked?

Answer this question