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

Can someone help me out with this knife kill script, it's erroring out /: ?

So I have a murder game and i'm trying to make a kill script, that if I click someone's root part or Torso, they die. But it's just erroring and ugh... I just need help. This script is a server script inside of serverscriptservice.

Script:

game.Players.PlayerAdded:Connect(function(player)
	local Mouse = player:GetMouse()
	if player.Backpack.EquippedTool == "DefKnife" then
		if Mouse.Target.Parent.Name == "HumanoidRootPart" or "Torso" then
			Mouse.Target.Parent.Parent.Humanoid.MaxHealth = 0
		end
	end
end)

3 comments

0

Is your output enabled? What is the error you're getting?

0

By "erroring" I mean not working. It won't kill /:

0

Try changing the Health instead of Max Health. Also, just make a script inside of the tool itself that is activated upon Activation or Equipping or whatever you want it to be.

1 answer

The issue here is in your if statement on line 4.

I believe your intention is to check if Mouse.Target.Parent.Name is "Humanoid" or "Torso", but you are checking if Mouse.Target.Parent.Name == "HumanoidRootPart" then, and separately checking if Torso then rather than if Mouse.Target.Parent.Name == "Torso" then.

Also, instead of setting the MaxHealth to 0, you could use the TakeDamage method from Humanoid, or simply set Health to 0.

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