Please help, i want to make a script so one of my models can try to kill people, but i have no idea how.
It depends on how you want it to work for the most part. A couple ways to damage/kill a player are-
Character:BreakJoints() Character.Humanoid:TakeDamage(50) Character.Humanoid.Health = 0
To sense touches you should use the Touched
event of a Part. If you're making some type of AI, I'd use the Touched
event of both its arms and make them damage players when touched. The script might look something like this-
local AI = script.Parent local LeftArm = AI:WaitForChild("Left Arm") local RightArm = AI:WaitForChild("Right Arm") function ArmTouched(part) local hum = part.Parent:FindFirstChild("Humanoid") if hum then -- a character must've touched the part hum:TakeDamage(math.random(5, 25)) end end LeftArm.Touched:connect(ArmTouched) RightArm.Touched:connect(ArmTouched)
This will make any part in the model(script.Parent) kill people.
model = script.Parent function Touched(part) if part.Parent:FindFirstChild("Humanoid") ~= nil then part.Parent.Humanoid.Health = 0 end end function ConnectParts(obj) if obj then if obj:IsA("Part") then obj.Touched:connect(Touched) else if #obj:GetChildren() > 0 then for i, v in pairs(obj:GetChildren()) do ConnectParts(v) end end end end end ConnectParts(model)