I am making a hockey game what I want in this script is when the hockey ball touched a part named "RedGoal" then the hockey ball gets removed.
RG = game.Workspace.RedGoal BG = game.Workspace.BlueGoal RS = game.Workspace.RedScore BS = game.Workspace.BlueScore script.Parent.Touched:connect(function(part) if part:ClassName("RedGoal") then script.Parent:remove() end end)
ClassName is not a method. It looks like you're just trying to check the Name.
Change
if part:ClassName("RedGoal") then
to
if part.Name == "RedGoal" then
I also recommend not using remove
and instead setting the Parent to nil or using Destroy
.