Skip to content

Commit

Permalink
Update blink and thru to ignore non-collidable parts
Browse files Browse the repository at this point in the history
  • Loading branch information
wilyt1 committed Aug 29, 2024
1 parent e2ece92 commit 7481ffb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
28 changes: 26 additions & 2 deletions Cmdr/BuiltInCommands/Debug/blink.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
local CollectionService = game:GetService("CollectionService")

for _, instance in workspace:GetDescendants() do
if instance:IsA("BasePart") and not instance.CanCollide then
instance:AddTag("RayBlacklist")
end
end

workspace.DescendantAdded:Connect(function(descendant)
if descendant:IsA("BasePart") and not descendant.CanCollide then
descendant:AddTag("RayBlacklist")
end
end)

return {
Name = "blink",
Aliases = { "b" },
Expand All @@ -12,11 +26,21 @@ return {
local mouse = context.Executor:GetMouse()
local character = context.Executor.Character

if not character then
if not (character and character:FindFirstChild("HumanoidRootPart")) then
return "You don't have a character."
end

character:MoveTo(mouse.Hit.p)
character:AddTag("RayBlacklist")

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = CollectionService:GetTagged("RayBlacklist")
raycastParams.IgnoreWater = true
raycastParams.CollisionGroup = "Default"

local raycastResult = workspace:Raycast(mouse.UnitRay.Origin, mouse.UnitRay.Direction * 1000, raycastParams)

character:MoveTo(if raycastResult then raycastResult.Position else mouse.Hit.Position)

return "Blinked!"
end,
Expand Down
28 changes: 26 additions & 2 deletions Cmdr/BuiltInCommands/Debug/thru.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
local CollectionService = game:GetService("CollectionService")

for _, instance in workspace:GetDescendants() do
if instance:IsA("BasePart") and not instance.CanCollide then
instance:AddTag("RayBlacklist")
end
end

workspace.DescendantAdded:Connect(function(descendant)
if descendant:IsA("BasePart") and not descendant.CanCollide then
descendant:AddTag("RayBlacklist")
end
end)

return {
Name = "thru",
Aliases = { "t", "through" },
Expand All @@ -19,12 +33,22 @@ return {
local mouse = context.Executor:GetMouse()
local character = context.Executor.Character

if not character or not character:FindFirstChild("HumanoidRootPart") then
if not (character and character:FindFirstChild("HumanoidRootPart")) then
return "You don't have a character."
end

character:AddTag("RayBlacklist")

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = CollectionService:GetTagged("RayBlacklist")
raycastParams.IgnoreWater = true
raycastParams.CollisionGroup = "Default"

local raycastResult = workspace:Raycast(mouse.UnitRay.Origin, mouse.UnitRay.Direction * 1000, raycastParams)

local pos = character.HumanoidRootPart.Position
local diff = (mouse.Hit.p - pos)
local diff = ((if raycastResult then raycastResult.Position else mouse.Hit.Position) - pos)

character:MoveTo((diff * 2) + (diff.unit * extra) + pos)

Expand Down

0 comments on commit 7481ffb

Please sign in to comment.