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

Please Answer. Region cannot be casted. What is wrong with the script?

Unable to cast Instance to Region3

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)


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 comment

0

Error is above line 10 or on it...

1 answer

Regions don't take a part. You already created your Region object. Use Area, not region. This is why you're supposed to keep proper naming conventions lol

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