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

Make a part that can kill players but not the one that casted it?

Im trying to make a part that kill the other players when touched but not the player that used it. Here is the script but its not working.

card.Touched:Connect(function(hit)
		if not debounce then
			if hit and hit.Parent then
				print(hit.Parent.Name)
				if not hit.Parent.Name == player.Character.Name then
					local hum = hit.Parent:FindFirstChild('Humanoid')
						if hum then
						hum:TakeDamage(2)
						debounce = true
					end
				end
			end
		end
	end)

1 answer

✓ Accepted answer

You never reset debounce. Typically the code is:

debounce = true
--action here
wait(0.1) -- or whatever cooldown you like
debounce = false

A superior version of line 5 is if not player == game.Players:GetPlayerFromCharacter(hit.Parent) then, as then it won't matter what things are named.

2 comments

0

Thanks

0

If you find an answer helpful you should accept it as the answer so people know that your problem has been solved

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