This is how to do it when clicked but how do you do it when touched?



this is when clicked but how do i do it when touched?

2 Likes

Pretty sure you could do
script.Parent.Touched:connect(function)

1 Like

I think this is what you’re going for:

local part = script.Parent
local playersService = game:GetService("Players")

part.Touched:Connect(function(partTouched)
	
	if partTouched.Parent:FindFirstChild("Humanoid") then
		
		if playersService:GetPlayerFromCharacter(partTouched.Parent) then
			
			-- when the part is touched script here
			
		end
		
	end
	
end)

If I was you I’d probably add a debounce (cool down) in order to reduce the load of this thread as touching the part would cause this function to run at a very high rate. (I can help with too if you want)

2 Likes

Ye could i have further support im quite new to scripting. Ill just have a think ill be 10 mins then let you know.

1 Like

hello, im back so do i put this in server script service?

1 Like

where is the part where i changed it to the part name that i have

1 Like

Yes, a server script. A local script will not be able to change the values for the server.

So i put it in server script service. Which bit do i change to make it apply to the name of my part. Or do i add another script.