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

How do I only make this apply to a single part?

So, I have some parts that damage you upon touching them. I put them all in a folder and made the damaging scripts into one. There's a problem, though. I applied debounce and it worked, but you couldn't be damaged by any of those parts for that amount of time. (I removed it in the script below.)

local b = script.Parent:GetChildren()

for i, c in pairs(b) do
	if c:IsA("BasePart") then
		c.Touched:Connect(function(obj)
			if game.Players:GetPlayerFromCharacter(obj.Parent) then
				local plr = obj.Parent
				plr.Humanoid:TakeDamage(50)
			end
		end)
	end
end

How would I make the debounce apply to only a single part?

1 comment

0

No need for debounce, just put the certain part you want with a different name of all the others, and then point the script toward that part.

1 answer

In this case, I would recommend instancing a boolean value under each part and that you don't have to deal with tables and can easily check if you can be damaged or not. If you have any questions, please reply to my answer.

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