So Im trying to make a script that I can go back and forth between collusion and not being collidable. It only works for noncollidable. I cant seem to figure out what the problem. Help?
Also, **if ** you add a explanation please make it highly detailed. I like to learn as much as I possibly can.
The only thing I can figure is it must be something small Im missing. ?? https://developer.roblox.com/api-reference/function/PhysicsService/RemoveCollisionGroup Though I dont want to fully remove the group, just the player from the group for the time being.. Cause they will be back and forth. Between lobby time and actual gameplay time.
So what Im asking is, what am I doing wrong?
local Players = game:GetService("Players")
local Physics = game:GetService("PhysicsService")
local PlayerGroup = Physics:CreateCollisionGroup("PlayerGroup")
SetPlayersAsCollidable = function()
Physics:CollisionGroupSetCollidable("PlayerGroup","PlayerGroup", true)
end
SetPlayersAsNonCollidable = function()
Physics:CollisionGroupSetCollidable("PlayerGroup","PlayerGroup", false)
end
CheckForCollusion = function(character)
for i,v in next,character:GetChildren() do
if v:IsA("BasePart") then
Physics:SetPartCollisionGroup(v, "PlayerGroup")
end
end
end
CheckForCollusion(Players.Player1.Character)
SetPlayersAsNonCollidable() -- Great, others cant collide with me.
-- Now if I try have player character collusion's; it doesn't work? Why? Explanation please?
SetPlayersAsCollidable()
