Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make my stand not have collide?

local PS = game:GetService("PhysicsService")
PS:CreateCollisionGroup("Player")
PS:CollisionGroupSetCollidable("Player","Player",false)
 
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character:WaitForChild("HumanoidRootPart")
        Character:WaitForChild("Head")
        Character:WaitForChild("Humanoid")
        for i,v in pairs(Character:GetChildren()) do
            if v:IsA("BasePart") then
                PS:SetPartCollisionGroup(v,"Player")
            end
        end
    end)
end)

https://gyazo.com/f8accc2ae6e7f33f2ebff8ee79b88353 How can I make this script work with the "bodyguard" or stand behind me?

1 answer

All you really need to do is add a recursive function to get all the baseparts in a model and to make them not collide with the "Player" collision group.

You just need to pass in your bodyguard and stand models into it and it should work.

local PS = game:GetService("PhysicsService")
PS:CreateCollisionGroup("Player")
PS:CollisionGroupSetCollidable("Player","Player",false)

local function noCollide(model)
	for _, v in pairs(model:GetChildren()) do
		if (v:IsA("BasePart")) then
			PS:SetPartCollisionGroup(v,"Player")
		end
		
		noCollide(v) --//To go through the entire model
	end
end

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character:WaitForChild("HumanoidRootPart")
        Character:WaitForChild("Head")
        Character:WaitForChild("Humanoid")
        
		noCollide(Character)
    end)
end)

--[[
Example usage for your problem:

local bodyGuard = (Bodyguard Model)
local stand = (Stand Model)

noCollide(bodyGuard)
noCollide(stand)
]]

This discussion is preserved as it was. New answers, comments, and votes are closed.