Why does get GetPartBoundsInBox keep making value false?

Hello, So bassicly i am checking if a part called “TreeHitBox” is touching a part and if it is a value will become true, But its sometimes false even when it is touching the tree’s hitbox, Heres a video:

When its red that means its touching a tree’s hitbox when it turns green it means its not touching a tree’s hitbox, And the even weirder thing is that its really random? Like sometimes 2 tree’s hitboxs actually work. Sometimes all of them work, Sometimes none of them work, Like before the recording it worked PERFECTLY but before that it worked horribly.

Heres the local script:

local RunService = game:GetService("RunService")

local Part = script.Parent

local Value = Part.HittingTree

RunService.Heartbeat:Connect(function()
	local filiter = OverlapParams.new()

	filiter.FilterDescendantsInstances = {Part}
	filiter.FilterType = Enum.RaycastFilterType.Exclude

	local cf, size = Part.CFrame, Part.Size
	local Parts = workspace:GetPartBoundsInBox(cf, size, filiter)
		
	for i, Child in ipairs(Parts)  do
		if Child.Name == "TreeHitBox" then
			if Value.Value == false then
				Value.Value = true
				Part.BrickColor = BrickColor.new("Really red")
			end
		elseif Child.Name ~= "TreeHitBox" then	
			if Value.Value == true then
				Value.Value = false
				Part.BrickColor = BrickColor.new("Lime green")
			end
		end
	end
end)

(The local script is located in a part in the workspace) heres the server script:

local PartGroup = game.Workspace:WaitForChild("Preview").PreviewHole

local UIS = game:GetService("UserInputService")

local Re = game.ReplicatedStorage.DUMB

local Pa = game.Workspace:WaitForChild("Pointingarea")

local Re2 = game.ReplicatedStorage.DUMB2

Re.OnServerEvent:Connect(function(Plr, Pos, Value)
	if Value == false then
local TA = Pos

	PartGroup.default.Position = Vector3.new(TA.X, 14.158, TA.Z)
	end
end)

the server script is located in server script service

How do i fix this??

break the loop if it finds the hitbox

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.