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

How do i make a pain region brick?

Hey, i'm in need of a brick that hurts a player when and ONLY when the PLAYER is INSIDE of the brick. Kind of like a hurting fog; but, i do not want the user to die immediately, i want them to just receive pain until left the INSIDE of the brick. Thanks!

1 answer

✓ Accepted answer

Something like this might work inside the part:

local function CreateRegion3FromLocAndSize(Position, Size)
	local SizeOffset = Size/2
	local Point1 = Position - SizeOffset
	local Point2 = Position + SizeOffset
	return Region3.new(Point1, Point2)
end
local reg = CreateRegion3FromLocAndSize(script.Parent.Position,script.Parent.Size)
while wait(1) do
	local parts = workspace:FindPartsInRegion3(reg,script.Parent,math.huge)
	for i,v in pairs(parts) do
		if v and v.Name == "HumanoidRootPart" and v.Parent:FindFirstChild("Humanoid") then
			v.Parent.Humanoid:TakeDamage(5) --change for damage
		end
	end
end

7 comments

0

Hey, i tried putting the exact code above into a script inside of the brick and it didn't work...

0

Any errors?

0

No errors... it seems that the code doesn't work...

0

I’ve altered the script to work with Region3s instead of Touched, you can try that instead. Keep in mind, if you need the region to be rotated, you will have to use this: http://wiki.roblox.com/index.php?title=User:EgoMoose/Articles/Rotated_region3

0

Great Job man, Lastly is there any way that this could work inside of a model? I am planning on combining bricks together, and i dont want them to deal double damage when the user is inside the overlapping bricks? Thanks

0

Yeah dude whenever the bricks are overlapping one brick does 0 damage, one does like 3, whenever i have takedamage(1) in the script...

0

The easiest thing would be to not overlap the bricks.

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