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

.Touched function to Region3 Not working?

I'm using a hitbox part on my sword and checking when the part is touched then I'm using region3 to do damage. But it won't work? Could I have missed something?

My Code:

Tool = script.Parent
Hitbox = Tool.Hitbox

Hitbox.Touched:Connect(function(Hit)
	local RTable = workspace:FindPartsInRegion3(Hitbox, nil, 20)
	
	for i,v in pairs(RTable) do
		if v.Parent:findFirstChild("Humanoid") and v.Parent:FindFirstChild("Deb") and v.Parent ~= Tool.Parent then
			local Deb = Instance.new("BoolValue", v.Parent)
			Deb.Name = "Deb"
			game.Debris:AddItem(Deb, 0.2)
			v.Parent.Humanoid:TakeDamage(10)
		end
	end
end)

1 answer

Why use region3? Why not just:

Tool = script.Parent
Hitbox = Tool.Hitbox
local isactivated
Hitbox.Touched:Connect(function(Hit)
if isactivated==false then
isactivated=true
Hit.Parent.Humanoid:TakeDamage(10)
wait(0.25)
isactivated=false
end
end)

4 comments

0

Because .Touched is unstable. And not safe to use

0

Says who? And your script still uses it...

0

To be honest I just want to use region3. And I heard .Touched can be changed by exploiters. Region3 is more smooth so I want to use that.

0

You're just making the script uneccesarily complicated. .Touched works fine, and there is no reason to use Region3, just use .Touched with a debounce (like my above script)

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