How do i make it so that when the local player touches a part it will follow the function

the title basically explains it all.

Can you please elaborate what you mean by follow the function? Just making sure if it is what I think it is.

well just like you know. It just follows what’s inside of the function.

I mean if you are trying to call a function after the player touches the part, you can use the commonly used .Touched event. I believe you can use it in both the server and local script, if I am wrong you can just use remote events to pass the arguments to a local script. To check if it is the player that touched the part, you can use GetPlayerFromCharacter(hit.Parent). Let me know if you have any questions or this was not what you meant.

how would you write that out in a function?

in the standard way?

like script.Parent.Touched:Connect(function()

1 Like
local part = script.Parent


function OnTouched(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		--you can continue the rest of your function here
	end
end


part.Touched:Connect(function(touchedPart)
	OnTouched(touchedPart)
end)
1 Like