Hi, I think I'm doing something wrong here. But heres a short explanation on what I intended this to do, as a player you can spawn in as a ghost (thats unneeded) but then make it so that you as a player are able to go through the ghost and the ghost can go through you, here is what I've made so far and It's not working;
Inside a module script;
local ps = game:GetService("PhysicsService") ps:CreateCollisionGroup("player") ps:CreateCollisionGroup("ghost") ps:CollisionGroupSetCollidable("ghost", "player", false) ps:CollisionGroupSetCollidable("ghost", "ghost", false) function module:RemoveCollisions(model) for a,b in pairs(model:GetChildren()) do if b:IsA("BasePart") then ps:SetPartCollisionGroup(b, "ghost") end end end function module:Ghosting(char) char:WaitForChild("HumanoidRootPart") char:WaitForChild("Head") char:WaitForChild("Humanoid") wait(0.1) module:RemoveCollisions(char) end
Inside a server script in ServerScriptService
remotes.ChangeRole.OnServerEvent:Connect(function(plr, char, changerole) if changerole == "Ghost" then local role = require(game.ReplicatedStorage.Roles.Ghost) role:Ghosting(char) -- this fires the Ghosting function in the module script end end)
Any help would be greatly appreciated, thank you so much for your time on reading my concerns.
You haven't set CollisionGroupSetCollidable
which determines the collidable status between two groups.
I am guessing that you made a typo in your explanation, because usually ghosts do not collide with normal players.
In order to accomplish ghosts being able to pass through players, you would need to make a collision group for normal players, as well as one for ghosts, and do something to the effect of:
ps:CollisionGroupSetCollidable("ghost", "player", false)
Make sure you add all players to the "player" group, and those who become ghosts you can set them to the "ghost" group.
Please let me know if you are already doing this, and I will edit my answer. I am working off the information you provide.
EDIT: Also, if you want ghosts to be able to go through other ghosts, make sure you set collisions between that group to be false
with itself:
ps:CollisionGroupSetCollidable("ghost", "ghost", false)
EDIT 2:
local players = game:GetService("Players") local ps = game:GetService("PhysicsService") ps:CreateCollisionGroup("players") ps:CreateCollisionGroup("ghost") --create collision groups ps:CollisionGroupSetCollidable("ghost", "player", false) ps:CollisionGroupSetCollidable("ghost", "ghost", false) --set collisions between ghosts and players, ghosts and ghosts function setCharGroup(char, group) for _, child in pairs(char:GetChildren()) do if child:IsA("BasePart") then ps:SetPartCollisionGroup(child, group) end end end --utility function to set the collision group for all baseparts in the character players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) setCharGroup(character, "player") end) end) --add all players to "player" collision group function ghost(char) setCharGroup(char, "ghost") end --ghosting function (example)