Hello! I have a flying tool in my game which I will post the script of. While walking, players can pass right through objects as intended, but when using the fly tool, they knock right into them as if CanCollide is checked!
Is there anything I can put in the script to make players able to properly communicate with these objects that are non-collidable? Note: not all objects, just the ones set to non-collidable!
Thank you so much!
Here is the script for the flying tool:
local FLY_SPEED = 30 --studs/second
local BODYOBJECT_NAME_PREFIX = "FLY_TOOL_"
local MAX_FORCE = Vector3.new(1, 1, 1) * math.huge --infinite force on each axis
local MAX_TORQUE = Vector3.new(1, 1, 1) * math.huge
local self = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local held = false
local character, human, torso, bv, bg, dir --variables to be used later
mouse.Button1Down:connect(function()
if bv then
held = true
while held do
bv.velocity = FLY_SPEED * (mouse.Hit.p - root.Position).unit
bg.cframe = CFrame.new(root.Position, mouse.Hit.p) * CFrame.Angles(-math.pi/2, 0, 0)
wait()
end
bv.velocity = Vector3.new()
bg.cframe = Workspace.CurrentCamera.CoordinateFrame
end
end)
mouse.Button1Up:connect(function()
held = false
end)
self.Selected:connect(function()
character = player.Character; if not character then return end
human = character:FindFirstChild("Humanoid"); if not human then return end
root = character:FindFirstChild("HumanoidRootPart"); if not root then return end
bv = Instance.new("BodyVelocity", root)
bv.Name = BODYOBJECT_NAME_PREFIX .. "BodyVelocity"
bv.maxForce = MAX_FORCE
bg = Instance.new("BodyGyro", root)
bg.Name = BODYOBJECT_NAME_PREFIX .. "BodyGyro"
bg.maxTorque = MAX_TORQUE
bg.cframe = root.CFrame
human.PlatformStand = true
end)
self.Deselected:connect(function()
held = false
if human then human.PlatformStand = false end
if bv then bv:Destroy() end
if bg then bg:Destroy() end
end)

2 comments
So if I am understanding correctly, the only way to pull this off is to be able to pass through everything? :( or could I replace .Workspace with the name of an object I don't want them to pass through and call the objects I don't want them to the same name? And where would I fit the mouse.TargetFilter = game.Workspace into the script?
If you put all the objects you want them to fly through in a seperate model you'll be able to target that model with mouse.TargetFilter --- The TargetFilter line can go directly below the GetMouse() line.