Can't understand touched functions

hello developers please can someone make me understand what are touched functions because i am making a obby so i want the part to fall after 2 seconds when a player steps on it :sweat_smile: :joy:

1 Like

To understand Basepart.Touched u need to understand RBXScriptSignals or more commonly called Events.

Every Event has a RBXScriptSignal:Connect and RBXScriptSignal:Wait function. Connect adds a new listener function to the Event, the first argument will be the function. All listener functions will be called when the Event gets fired. Wait waits for the Event to fire, wait yeilds to script until the event gets fired.

You can create custom Events using BindableEvents

.Touched gets fired when the basepart gets touched, passed the basepart who touched the basepart as parameter.

Example

local part = workspace.Part -- Get a part named Part in workspace

part.Touched:Connect(function(hit) -- Add a function to the .Touched event
  print(hit.Name .. " has touched")
end)
1 Like

ok :sweat_smile: i will try it