How would I disable tool collisions without making it fall into the void? I want it so that parts of the tool don't collide or get stuck with anything. Because if you could see in this game which is mine, the tools are not handling very well. I mostly get complains wherein the guns get stuck within the walls.
rather than trying to make the tools completely uncollidable, you could try making them uncollidable when a player is holding them, but collidable otherwise
local tool = script.Parent local Players = game:GetService("Players") -- scripts don't run when they're in the player's backpack so you have to check if the tool is already owned by a player when it gets re-parented, or else it might fall into the void local function setCollidability(collidability) for _, descendant in pairs(tool:GetDescendants()) do if descendant:IsA("BasePart") then descendant.CanCollide = collidability end end end local owner = Players:GetPlayerFromCharacter(tool.Parent) setCollidability(not owner) -- not gives you the opposite of a value's truthiness, so using not here is like saying "if there's an owner, then set CanCollide to false" tool.Equipped:Connect(function() setCollidability(false) end) tool.Unequipped:Connect(function() setCollidability(true) end)
if you want some parts to ALWAYS be uncollidable then you could iterate over descendants of the tool and give them an "OriginalCollidability" value, where if it's false the part will always be uncollidable and if it's true its collidability will be able to change
you could also use collision groups and just set the part's collision group beforehand, which does the work for you
local PhysicsService = game:GetService("PhysicsService") local defaultGroup = PhysicsService:GetCollisionGroupName(0); local playerGroup = "PlayerGroup"; local npcGroup = "NPCGroup"; PhysicsService:CreateCollisionGroup(playerGroup); PhysicsService:CreateCollisionGroup(npcGroup); function setNPCGroup(char) for i,v in pairs(char:GetDescendants()) do if (v:IsA("BasePart")) then PhysicsService:SetPartCollisionGroup(v, npcGroup); end end end function setPlayerGroup(char) for i,v in pairs(char:GetDescendants()) do if (v:IsA("BasePart")) then PhysicsService:SetPartCollisionGroup(v, playerGroup); end end end
This can disable colliding between npc and players.