How does this script detect touching!?

I was messing around with a freemodel where I stumbled across this code in a LocalScript. How does this work!? it is basically a touch detecter in a LocalScript, which is weird!

function connectplrtouch(pt,func)
	pt.Touched:Connect(function(t)
		local c=game.Players.LocalPlayer.Character
		if c and t:IsDescendantOf(c) then
			func()
		end
	end)
end
1 Like

I guess the pt.Touched:Connect(function(t)

1 Like

A touch detector in a LocalScript is perfectly fine, actually! I am a bit confused on how it would work, since the event is in the function, and there isn’t any parameters to pass for “pt” and “func”… :thinking:

yeah, how does it know what pt is? also, this only works for two parts lol, i made another part that was just in the WS, and nothing happened, so this is genius lol

You should’ve read the context better before posting this. Try finding which part of the code that uses this function and examine its arguments.

Yes, but this is in a LocalScript, and LocalScripts can detect touching functions?

1 Like

Of course it can, also it’s not a function, it’s called an event.

1 Like

Sorry, that is what I meant, I took a probably way too long break from developing