Hello so I’m new and i made a script that has a block follow players. Im trying to have it Deal damage to them on touch but I’m not sure how to do that. Here is what i thought would work but it didnt lol.
if workspace.Pet.Position == game.Players.LocalPlayer.Character.Humanoid then game.Players.LocalPlayer.Character.Humanoid:TakeDamage(100)```
Could someone please help? :slight_smile:
You can use a .Touched event to detect when the part touches a character.
Basic Example:
--you would want this to be a server script since it handles all the players at once.
Workspace.Pet.Touched:Connect(function(touchedpart) --this will only work if Workspace.Pet is a "Part", or another instance with the .Touched event.
if touchedpart.Parent:FindFirstChild("Humanoid") then --a check to make sure the touched part is inside the character model
touchedpart.Parent:FindFirstChild("Humanoid"):TakeDamage(100) --damage the player
end
end)