TouchEnded is an event, not a bool value. You can make it a bool value like this:
local partTouching = nil
local touchPart = script.Parent
touchPart.Touched:connect(function(part)
partTouching = part
repeat
script.Parent.BrickColor = BrickColor.new("Institutional white")
wait(1)
script.Parent.BrickColor = BrickColor.new("Really black")
wait(1)
until not partTouching
end)
touchPart.TouchEnded:connect(function(part)
if part == partTouching then
partTouching = nil
end
end)
If you have any questions or issues, feel free to comment below.
7 comments
what is the rest of this script?
That's it.
cant you do a touched event and a touchended event?
Think of it like this, if you have a base plate then the part is calling Touched and Touch Ended event multiple times. Also you need to define the player.
If I'm doing if game.Workspace.Part.Touched Can I still find the part that touched it?
yes, that is one of the arguments of the touched event
TouchEnded cannot be used like this, it's an event.