Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a pain region brick?

Asked by 6 years ago

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

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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
0
Hey, i tried putting the exact code above into a script inside of the brick and it didn't work... dontyoucare 0 — 6y
0
Any errors? mattscy 3725 — 6y
0
No errors... it seems that the code doesn't work... dontyoucare 0 — 6y
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 mattscy 3725 — 6y
View all comments (3 more)
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 dontyoucare 0 — 6y
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... dontyoucare 0 — 6y
0
The easiest thing would be to not overlap the bricks. mattscy 3725 — 6y
Ad

Answer this question