How to I add a event that happens when a player steps on a block?
You use the .Touched
event.
This code kills the player when they step on the part.
Part.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:BreakJoints() end end)
Hit is the object that hit the part, we can use an if statement to check to see if the object's parent has a humanoid and if it does then it might be a player, to check if it is a player we can do
Part.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") and game:GetService("Players")[Hit.Parent.Name] then -- code end end)
https://www.robloxdev.com/api-reference/event/BasePart/Touched