Skip to content

Instantly share code, notes, and snippets.

@Parihsz
Created November 24, 2023 00:36
Show Gist options
  • Select an option

  • Save Parihsz/8b55fd9e531b26b49e14550c65398257 to your computer and use it in GitHub Desktop.

Select an option

Save Parihsz/8b55fd9e531b26b49e14550c65398257 to your computer and use it in GitHub Desktop.
find edges
local function FindEdges(Object, Directional)
local _CF = Object.CFrame
local Size = Object.Size
local function UpdateCFrame(CF, direction)
local Directions = {
["Top"] = CF + CF.UpVector * (Size.Y/2),
["Bottom"] = CF + CF.UpVector * -(Size.Y/2),
["Left"] = CF + CF.RightVector * -(Size.X/2),
["Right"] = CF + CF.RightVector * (Size.X/2),
["Front"] = CF + CF.LookVector * (Size.Z/2),
["Back"] = CF + CF.LookVector * -(Size.Z/2)
}
return Directions[direction]
end
local Directional = string.split(Directional, " ")
for i = 1,3 do
_CF = UpdateCFrame(_CF, Directional[i])
end
return _CF
end
local function VisualEdge(Edge)
local Cube = Instance.new("Part")
Cube.Size = Vector3.one
Cube.CFrame = Edge
Cube.Material = Enum.Material.Neon
Cube.Color = Color3.fromRGB(255, 0, 0)
Cube.CanQuery = false
Cube.Anchored = true
Cube.Parent = workspace
end
VisualEdge(FindEdges(workspace.Egder, "Top Front Left"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment