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

Region script. Region3 does not exist. What did I do wrong? Script does not work.

"Unable to Cast Instance to Region3" line 16

local region = game.Workspace.RegionPart
local pos1 = region.Position - (region.Size/2)
local pos2 = region.Position + (region.Size/2)
local Area = Region3.new(pos1, pos2)
local part = script.Parent
part.CFrame = Area.CFrame
--[[local part = Instance.new("Part")
part.CanCollide = false
part.Anchored = true
part.Size = region.Size
part.Parent = game.Workspace
part.Transparency = 0.5]]--
while true do 
	Debounce = true
	wait()
	local PartInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
	for i, part in pairs(PartInRegion) do
		if part.Parent:FindFirstChild("Humanoid") ~= nil then
			Debounce = false
			print("Player Found"..part.Parent.Name)
			local Workspace  = part.Parent
			Workspace.Humanoid:TakeDamage(Workspace.Humanoid.MaxHealth)
			Debounce = true
		end
	end
end

1 answer

You forgot to uncomment line 13. Check if this works:

local region = game.Workspace.RegionPart
local pos1 = region.Position - (region.Size/2)
local pos2 = region.Position + (region.Size/2)
local Area = Region3.new(pos1, pos2)
local part = script.Parent
part.CFrame = Area.CFrame
--[[local part = Instance.new("Part")
part.CanCollide = false
part.Anchored = true
part.Size = region.Size
part.Parent = game.Workspace
part.Transparency = 0.5]]--


while true do 
    Debounce = true
    wait()
    local PartInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
    for i, part in pairs(PartInRegion) do
        if part.Parent:FindFirstChild("Humanoid") ~= nil then
            Debounce = false
            print("Player Found"..part.Parent.Name)
            local Workspace  = part.Parent
            Workspace.Humanoid:TakeDamage(Workspace.Humanoid.MaxHealth)
            Debounce = true
        end
    end
end

2 comments

0

It doesn't have to do anything with the comment

0

oh...

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