Flag drops on where it wasn't supposed to drop

I’ve been trying to fix for at least a day now and I still don’t know why and how this is possible

image

Code

local flagPosition = tool.Flag:GetPivot()

local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true
raycastParams.FilterType = Enum.RaycastFilterType.Include
raycastParams.FilterDescendantsInstances = {
	workspace.Terrain,
	workspace.Rocks,
	workspace.Bridge,
	workspace.Barrels
}

local raycast = workspace:Raycast(
	flagPosition.Position + Vector3.new(0, 10, 0),
	flagPosition.Position - Vector3.new(0, 100, 0),
	raycastParams
)

local position = raycast and raycast.Position or flagPosition.Position

bodyAttach.Anchored = true
tool.Flag:PivotTo(CFrame.new(
	(recentlyCaptured and
		spawns:FindFirstChild(company.Value.Parent.Name):GetPivot().Position
	or position))
)
recentlyCaptured = false
1 Like

i dont get what youre trying to do, where is the flag supposed to go

What’s the point of adding 10 then removing 100? Just curious.