I need to make it so that when the enemy attacked you, he did not hit from you, but just either stopped or passed through you, how to do it? That’s what I have right now:
And I need to do so that it does not hit me like this, that is, I want to remove the coliseum, but I do not know how to do it, please advise me.
And can you give an example of how to do this, how to give players one colision “player” and monsters the second “monster” and make it so that they do not touch each other
Disabling Character Collisions explains how to set all parts of a player’s character to be in a collision group on spawn. For the NPCs, you could just set the collision group while you’re still in studio without scripts. Creating the two groups and adjusting them to not collide with each other can be done in studio too
Here is an example of how to do that in case you are still looking.
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:RegisterCollisionGroup("Npcs")
PhysicsService:CollisionGroupSetCollidable("Players", "Npcs", false)
--[[
If you want to avoid collisions between players or NPCs
PhysicsService:CollisonGroupSetCollidable("Players", "Players", false)
PhysicsService:CollisonGroupSetCollidable("Npcs", "Npcs", false)
]]
local function AddCharacterToCollisionGroup(Character, CollisionGroup)
for Index, Part in Character:GetDescendants() do
if not Part:IsA("BasePart") then continue end
Part.CollisionGroup = CollisionGroup
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
AddCharacterToCollisionGroup(Character, "Players")
end)
end)
Ok I created a script in serverscriptService, and pasted your script there, but it doesn’t work, what else do I need to add to make it work?
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:RegisterCollisionGroup("Npcs")
PhysicsService:CollisionGroupSetCollidable("Players", "Npcs", false)
--[[
If you want to avoid collisions between players or NPCs
PhysicsService:CollisonGroupSetCollidable("Players", "Players", false)
PhysicsService:CollisonGroupSetCollidable("Npcs", "Npcs", false)
]]
local function AddCharacterToCollisionGroup(Character, CollisionGroup)
for Index, Part in Character:GetDescendants() do
if not Part:IsA("BasePart") then continue end
Part.CollisionGroup = CollisionGroup
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
AddCharacterToCollisionGroup(Character, "Players")
end)
end)
ok, you just need to add the characters to collision group at the beginning of the game and when they are added to the folder.
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("Players")
PhysicsService:RegisterCollisionGroup("Npcs")
PhysicsService:CollisionGroupSetCollidable("Players", "Npcs", false)
local NpcsFolder = workspace.Npcs -- Npcs folder
--[[
If you want to avoid collisions between players or NPCs
PhysicsService:CollisonGroupSetCollidable("Players", "Players", false)
PhysicsService:CollisonGroupSetCollidable("Npcs", "Npcs", false)
]]
local function AddCharacterToCollisionGroup(Character, CollisionGroup)
for Index, Part in Character:GetDescendants() do
if not Part:IsA("BasePart") then continue end
Part.CollisionGroup = CollisionGroup
end
end
for Index, Npc in NpcsFolder:GetChildren() do
AddCharacterToCollisionGroup(Npc, "Npcs")
end
NpcsFolder.ChildAdded:Connect(function(newNpc)
AddCharacterToCollisionGroup(newNpc, "Npcs")
end)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
AddCharacterToCollisionGroup(Character, "Players")
end)
end)