Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update blink and thru to ignore non-collidable parts #337

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading