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

Script does not kill at all on touched?

Hi, I have a problem where my script just will not kill at all for some reason. There aren't any errors, it registers .Touched, it just will not kill!

Here's the code:

Humanoid = script.Parent:WaitForChild("Humanoid")
local debounce = false

function award(plr)
	if not game.BadgeService:UserHasBadgeAsync(plr.UserId, 2124571974) then
		game.BadgeService:AwardBadge(plr.UserId, 2124571974)
	end
end

function onTouch(hit)
	print(hit)
	if debounce ~= true then
		debounce = true
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local currentplayer = game.Players:GetPlayerFromCharacter(script.Parent)
		print(player)
		print(currentplayer)
		if player and currentplayer then
			if hit.Parent.ClassName == "Tool" or hit.Parent.Name == "Handle" then
				currentplayer.Character:BreakJoints()
			end
			if currentplayer.TeamColor == BrickColor.new("Really red") then
			if player.UserId == 111255307 then
				award(currentplayer)
			elseif player.UserId == 424716966 then
				award(currentplayer)
			elseif player.UserId == 109352342 then
				award(currentplayer)
		end
	end
end
	end
	wait(2)
	debounce = false
end

if Humanoid.RigType == Enum.HumanoidRigType.R6 then
	script.Parent:WaitForChild("Torso").Touched:Connect(onTouch)
else
	script.Parent:WaitForChild("UpperTorso").Touched:Connect(onTouch)
end

while true do
	wait(0.1)
	Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end

The most important part is this:

if hit.Parent.ClassName == "Tool" or hit.Parent.Name == "Handle" then
	currentplayer.Character:BreakJoints()
end

I have no idea why this doesn't work. Please help!

1 comment

0

What about making class name like humanoid maybe??

2 answers

If everything else in your script is all good then this should work.

Try doing...

currentplayer.Character.Humanoid.Health = 0

5 comments

0

If that doesnt work its most likely an issue with the other parts of the script.

0

yeah it doesn't work for some reason

0

Id suggest rescripting it, and test it after like every line of code to make sure it works.

0

Id suggest using humanoid:TakeDamage(100) instead of that

0

I dont think itd make a difference since the rest of his script is what the problem is.

I just decided to rescript and change my badge. Thanks for the help!

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