-
What do you want to achieve?
Im trying to make it so humanoids are not Colliding with players and eachother -
What is the issue?
I don’t know how to do it -
What solutions have you tried so far?
I looked in dev forum
I tried ussing collision groups
and ussing yt tutorial
i think it is impossible unless you remove the Humanoid Object which does not fix the problem
it is possible as i seen many games do it but i don’t know how
collision filtering
i tried that and it did ot work
local PhysicsService = game:GetService("PhysicsService")
local Players = "Players"
local Units = "Units"
PhysicsService:CreateCollisionGroup(Players)
PhysicsService:CreateCollisionGroup(Units)
PhysicsService:CollisionGroupSetCollidable(Units, Players, false)
PhysicsService:CollisionGroupSetCollidable(Players, Players, false)
PhysicsService:CollisionGroupSetCollidable(Units, Units, false)
PhysicsService:CollisionGroupSetCollidable(Players, Units, false)
for i,v in pairs(game.Workspace.Allies:GetChildren()) do
PhysicsService:SetPartCollisionGroup(v.HumanoidRootPart, Units)
end
for i,v in pairs(game.Workspace.Enemies:GetChildren()) do
PhysicsService:SetPartCollisionGroup(v.HumanoidRootPart, Units)
end
game.Players.PlayerAdded:Connect(function(player)
for i,v in pairs(player.Character:GetChildren()) do
PhysicsService:SetPartCollisionGroup(v.HumanoidRootPart, Players)
end
end)
i tried this and it doesn’t work it
due to this issue
this is how you can add all parts inside a character to a collision group
local physicsService = game:GetService("PhysicsService")
-- when a player enters the game call this function
game.Players.PlayerAdded:Connect(function(player)
-- when a players character has finished loading
player.CharacterAppearanceLoaded:Connect(function(character)
-- loop everything inside the players character model
for i, descendant in ipairs(player.Character:GetDescendants()) do
-- if the descendant is not a basepart then we skip this descendant
if descendant:IsA("BasePart") then continue end
-- add the descendant to the Players collision group
physicsService:SetPartCollisionGroup(descendant, "Players")
end
end)
end)
i would recommend creating the collision groups inside of studio
if your not sure how to do that in this video at 7:10 i show how to create and add instances to a collision group
but what about humanoids that get cloned into certain directory(by that im asking to can i just put it in a loop not to be fired by player added or no)(also thanks for showing me how i can add entire player into collision group)
that’s not collision group’s problem, that’s your GetChildren() problem. Either the Enemies, Allies folder or the player.Character do not exist.
this should work on CS, iv used it before:
game:GetService('RunService').Stepped:Connect(function()
for i,v in next,game.Players.LocalPlayer.Character:GetChildren() do
if v:IsA('BasePart') then
v.CanCollide = false
end
end
end)
It’s the same logic
So when your enemy, allies folder and players added, you loop through every single basepart inside the child that is added and set the collision group
If you need the script for it, I can provide it to you as I have one of those in my project. I would suggest you trying it yourself first though
if your cloning enemy’s the clone will have the same collision group set so you don’t need to loop the clones every time
you can even just set the collision group manually in studio like i show in my video and then when you clone the enemy from serverstorage or where ever your keeping your enemy’s the clone will have the same collision group
but when the players character spawns its not a clone Roblox generates a brand new character so we must loop the players character every time it spawns