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

How to detect if another part has touched another part? [Solved]

Ok, I am doing a project for a coding class I do which we are learning how to script roblox. I am making a racing game for my project. I want to make it so when the finish part is touched by a red car, a message will say "Red Player has won!" or if it's blue: "Blue Player has won!"

This is what I have so far:

if workspace.EndLine.Touched then
	local message = Instance.new("Message")
	message.text = "A Player has won!"
	wait(4)
	message:Destroy()
end

Thank you sweet peeps.

  • RGames1234 (happy spooptober)

1 answer

✓ Accepted answer

chief called and said this is it

workspace.EndLine.Touched:connect(function(hit)
local touchedpart = hit.Parent
if touchedpart:IsA("BasePart") then
-- rest of code

4 comments

0

It seems to be conflicting with the rest of my code. ._. These are the two lines conflicting: 'workspace.EndLine.Touched:connect(function(hit)' (Your code) 'function respawnCars()' My car respawning function. Roblox says this is the issue: "11:34:57.481 - ServerScriptService.Script:15: ')' expected (to close '(' at line 3) near 'function'" If you can fix this, you are really cool. Thanks.

0

Make sure theres a parenthesis after the last end (i.e. "end)" )

0

Awesome, thanks bro. :P

0

Even though this is solved, you should use :Connect instead of :connect because :connect is deprecated, so use :Connect.

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