Why is this script not working?

I am trying to print Touched when player touches a part in client but its not working its not printing anything

script.Parent.Touched:Connect(function()
	print("Touched")
end

You can’t fire touch event from local script. You can only fire it from server script.

Try this code: (be sure this code is in script not localScript)

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		print("Touched")
	end
end)
1 Like

you need to put a ) at the end so do end) and not just end

You CAN call the Touched event in a LocalScript. The problem is that the LocalScript is a descendant in Workspace. LocalScripts dont work in Workspace (unless the localscript is a child of a player’s character). You can place the LocalScript somewhere else, maybe StarterPlayerScripts.

However, using a Server Script is much better to use when calling the Touched event. Unless you have certain reasons to use a LocalScript for calling the Touched event, its better off using a Server Script anyways.

1 Like