Still have questions? Join our Discord server and get real time help.
0

# How to disable Tool Collisions?

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.

1
Elyzzia 1023
4 days ago
Edited 4 days ago

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

0
thx elyzzia you're the best i hope u still remmeber me from server w xxIamInevitable 2 — 3d
-1
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.