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

Why doesn't this kill me when I'm holding the Coffee?

My code is

local part = script.Parent
local detector = part.ClickDetector
local cup = Player.Character:FindFirstChild("Decaf") or player.Character:FindFirstChild("Mocha") or player.Character:FindFirstChild("Regular") or player.Character:FindFirstChild("Frappe") or player.Character:FindFirstChild("HotCococa") or player.Character:FindFirstChild("Latte")
local debounce = false 

local function onPartTouched(otherPart)

	local partParent = otherPart.Parent

	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then

		if cup then
	humanoid.Health = 0
	end
	end
end


part.Touched:Connect(onPartTouched)

Shouldnt this kill me if I have on of those cups in my hand?

1 comment

0

Is this all your code? You're not leaving anything out? Because Player is a variable, what is it?

1 answer

Please try using this script if it works:

--Please add a variable for "player"

local function ontouched(object)
    local humanoid = object.Parent:FindFirstChild("Humanoid")
    if humanoid then
		if Player.Character:FindFirstChild("Decaf") or player.Character:FindFirstChild("Mocha") or player.Character:FindFirstChild("Regular") or player.Character:FindFirstChild("Frappe") or player.Character:FindFirstChild("HotCococa") or player.Character:FindFirstChild("Latte") then
			humanoid.Health = 0
		end
    end
end

script.Parent.Touched:Connect(ontouched)

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