So title explains it all thorougly, here is what i have.
head = game.Players.LocalPlayer.Character.Head
head:touched(part) part:destroy end
try this
local Player = game.Players.LocalPlayer Player.Character.Head.Touched:Connect(function(obj) if hit:IsA("BasePart") then obj:Destroy() end end)
and you can put this script automatically in a players head by using
local ReplicatedStorage = game:GetService("ReplicatedStorage") game.Players.PlayerAdded:Connect(function(plr) local script = ReplicatedStorage.script:Clone() -- replace .script with the name of the script script.Parent = plr.Charatcer.Head end)
make sure to put the top script in replicated storage and the bottom one in serverscriptservice This will destroy any object the players head touches with the class BasePart
Simple answer: BasePart.Touched.
Lemme explain.
part.Touched:Connect(function(hit) if hit:IsA("BasePart") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent) if player then if hit.Name == "Head" then part:Destroy() end end end end)
This works by using what's called the Touched event. It uses a base part(part, mesh, union, etc) and when something else touches it it fires our function. The hit argument is what touched it. Here we check if it's a real player and if it is we destroy it.