Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script is not killing me for some reason?

What the problem is is that when I have my arm it would not kill me but it would not let me go through which is good but still the part that I don't know what I did wrong but if I have a arm it wouldn't kill me.

local part = script.Parent

function onTouch(hit)
	local Player = hit.Parent
	if Player:FindFirstChild('Right Arm') == nil then
		part.CanCollide = false
		
		part.Transparency = 0.6
		
		wait(2)
		
		part.Transparency = 0
		
	else
		local Guy = script.Parent:FindFirstChild('Humanoid')
		
		part.CanCollide = true
		
		part.Transparency = 0
		
		Guy.Health = 0
	end
end
part.Touched:connect(onTouch)

1 comment

0

If you have any self-removing parts (ex bullets), you should add "if Player == nil then return end" right after line 4

2 answers

✓ Accepted answer

On line 21 do "Guy.Humanoid.Health = 0"

local Guy = script.Parent:FindFirstChild('Humanoid')

should be

local humanoid = Player:FindFirstChild('Humanoid')
if not humanoid then return end
humanoid.Health = 0

This discussion is preserved as it was. New answers, comments, and votes are closed.