I've tried scripting a kill part but no success. My code is:
01 | local part = script.Parent |
02 |
03 | part.Touched:Connect( function () |
04 | local player = game.Players.LocalPlayer |
05 | local character = player.Character |
06 | local hum = character:FindFirstChild( "Humanoid" ) |
07 | if hum then |
08 | hum.Health = 0 |
09 | end |
10 | end ) |
01 | local Part = script.Parent |
02 |
03 | function onTouched(hit) |
04 |
05 | if hit and hit.Parent then |
06 |
07 | local humanoid = hit.Parent:FindFirstChildOfClass( "Humanoid" ) |
08 |
09 | if humanoid then |
10 |
11 | humanoid:TakeDamage( 0 ) --Change this number to your damage with each touch |
12 | end |
13 | end |
14 | end |
15 |
16 | Part.Touched:Connect(onTouched) |
Sorry, I'm bad at explaining. You have to be sure that this is a server script and not a local one.
Since there are godmode exploit scripts out there, I'd recommend doing it this way:
01 | script.Parent.Touched:Connect( function (hit) --Checks if the part has been touched |
02 | if hit and hit.Parent:FindFirstChild( "Humanoid" ) then --If the thing that touched it has a Humanoid, it'll fire script below. |
03 | local NeckBind = hit.Parent:FindFirstChild( "Head" ):FindFirstChildWhichIsA( "Motor6D" ) --Checks for the Motor6D that connects the Head to the Neck. |
04 | if NeckBind and NeckBind.Name = = "Neck" then --If there's a Motor6D called Neck then |
05 | NeckBind:Destroy() --Destroys Neck Motor6D |
06 | else --If there's no Neck Motor6D |
07 | hit.Parent.Humanoid.Health = 0 --Changes health to 0, Kills player. |
08 | end ) |
09 | end ) |
10 | end ) |
I don't know if this will work, I will check later and edit this with a working script.
In a part put that script:
1 | script.Parent.Touched:connect( function (hit) |
2 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) then |
3 | hit.Parent.Humanoid.Health = 0 |
4 | end |
5 | end ) |