Why wont it understand a simple touch event?

If you send me a place file I can probably fix it.

The problem is probably that:

  • The name of the hit BasePart isn’t “Ball”
    • Test: Add a print or breakpoint before the if statement
  • The code isn’t running
    • Test: Add a print or breakpoint before the Connect function
  • The collisions are set incorrectly.
    • Fix: Check collision groups, check BasePart.CanTouch, check BasePart.CanCollide
  • The two parts aren’t colliding (unlikely).
    • Fix: Check if there are parts in the way of goal1

1,3 and 4 are working but I don’t understand 2.

Simply the code literally doesn’t run. It could be located somewhere where scripts don’t run (like outside of Workspace and ServerScriptService) or it’s Disabled.

It is in ServerScriptService, and is not disabled.

1 Like

Not sure then. I’d try restarting studio and double checking the things I wrote above. You can also send a place file with just that script and the parts and I can give it a go.

Could you please provide a picture of the workspace goal and ball. And both their properties.

local goal1 = workspace.goal1

goal1.Touched:Connect(function(part)
	if part.Name == "Ball" then
		print("Blue scored a goal")
		game.ReplicatedStorage.BlueGoals.Value = game.ReplicatedStorage.BlueGoals.Value + 1
		Ball.Position = originalPosition
		Ball.Anchored = true
		wait(2)
		Ball.Anchored = false
	end
end)

Needs to be a server script, place it in workspace. Also the part named “goal1” must be named “goal1” as seen in explorer, same with “Ball” that part must also be named “Ball” as seen in explorer.

I think what he means is put more prints in strategic places so you know what it IS doing. 1) before the function is even called, 2) after touched is fired but before any other logic

image

if print#1 doesn’t work your script isn’t running
if print#2 doesn’t work your touched isn’t firing

The script isn’t even running, and it is in the ServerScriptService and is not disabled, so i am going to completely remake the game. Thanks for the help! :slight_smile:

oof. i just realised it was the invis walls. thanks for the help tho!