I’ve been trying to fix for at least a day now and I still don’t know why and how this is possible
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