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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
rokedev 71
6 years ago

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
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. RGamesDev 22 — 6y
0
Make sure theres a parenthesis after the last end (i.e. "end)" ) Vulkarin 581 — 6y
0
Awesome, thanks bro. :P RGamesDev 22 — 6y
0
Even though this is solved, you should use :Connect instead of :connect because :connect is deprecated, so use :Connect. InstantManager 27 — 6y
Ad

Answer this question