I have a CollisionGroupId LocalScript in StarterCharacterScripts that Doesnt Work, could you give me suggestions or help on this?
script:
char = game.Players.LocalPlayer.Character
char.RightFoot.CollisionGroupId = 2
char.LeftFoot.CollisionGroupId = 2
char.RightLowerLeg.CollisionGroupId = 2
char.LeftLowerLeg.CollisionGroupId = 2
char.RightUpperLeg.CollisionGroupId = 2
char.LeftUpperLeg.CollisionGroupId = 2
char.LowerTorso.CollisionGroupId = 2
char.UpperTorso.CollisionGroupId = 2
char.Head.CollisionGroupId = 2
char.LeftHand.CollisionGroupId = 2
char.RightHand.CollisionGroupId = 2
char.LeftLowerArm.CollisionGroupId = 2
char.RightLowerArm.CollisionGroupId = 2
char.LeftUpperArm.CollisionGroupId = 2
char.RightUpperArm.CollisionGroupId = 2
char.HumanoidRootPart.CollisionGroupId = 2
workspace.Ball.CollisionGroupId = 2
I still Collide with the ball (the ball is unanchored)
Its probably to do with collision settings
so help would be nice!
You’re using the wrong type of script. Both the character and ball are serverside, so the localscript won’t do anything.
I’ve rewritten it so it will work in a normal script in startercharacterscripts.
char = script.Parent
char.RightFoot.CollisionGroupId = 2
char.LeftFoot.CollisionGroupId = 2
char.RightLowerLeg.CollisionGroupId = 2
char.LeftLowerLeg.CollisionGroupId = 2
char.RightUpperLeg.CollisionGroupId = 2
char.LeftUpperLeg.CollisionGroupId = 2
char.LowerTorso.CollisionGroupId = 2
char.UpperTorso.CollisionGroupId = 2
char.Head.CollisionGroupId = 2
char.LeftHand.CollisionGroupId = 2
char.RightHand.CollisionGroupId = 2
char.LeftLowerArm.CollisionGroupId = 2
char.RightLowerArm.CollisionGroupId = 2
char.LeftUpperArm.CollisionGroupId = 2
char.RightUpperArm.CollisionGroupId = 2
char.HumanoidRootPart.CollisionGroupId = 2
game.workspace.Ball.CollisionGroupId = 2
Oh, ok I will try that and hope it works
I also noticed your original script just says “workspace”. Workspace is a service and should be referred to as “game.workspace” in order to avoid errors.
For the love of David Baszucki, I GET IT! I’m still probably going to type game.workspace out of muscle memory, but I understand that workspace won’t break your script.
Thanks for you help but the only problem is that i still collide with the ball, is there some collisiongroup problemor something?
baseparts
(baseparts)
August 18, 2022, 6:57pm
#6
This is actually not true. Using only “workspace
” is a shortcut and I actually always use it. It’s just what you prefer.
3 Likes
please for the love of the holy christ take some time to learn about for loops, it will save so much time
char = script.Parent
for _, charPart in pairs (char:GetChildren())
if charPart:IsA(“MeshPart”) or charPart:IsA(“Part”) then
charPart.CollisionGroupID = 2
end
end
workspace.Ball.CollisionGroupId = 2
apologies for any spelling mistakes or errors in the script, i’m on mobile currently
its not the script, its something about the collision, i still cant go through the ball
can you send a screenshot of the explorer maybe?
how do I screenshot my Explorer?
press the windows button
type “snip”
click “snipping tool”
click “new”
drag the square over the explorer
click “file”
click “save”
Its just your localscript in starterCharacterScript
ianplus
(ianplus)
August 18, 2022, 7:26pm
#14
uhh
local char, colId = script.Parent, 2
for _,charPart in pairs(char:GetChildren()) do
if charPart:IsA("BasePart") then
charPart.CollisionGroupID = colId
end
end
workspace.Ball.CollisionGroupId = colId
1 Like
I tried doing two parts with a collisiongruopid set to 3 and they still collided, so it not the script.
read this articlel; it might help you:
Collision Filtering | Roblox Creator Documentation
use serverscripts
{
physics_Service=game:GetService("PhysicsService")
physics_Service:CreateCollisionGroup("GroupName",IdNum)
physics_Service:CollisionGroupSetCollidable("GroupName","GroupName",boolean)
}
also use server script with a code like:
{
my_Character=script.Parent
for i,v in pairs(my_Character:GetChildren())do
if v:IsA("Part") or v:IsA("MeshPart")then
v.CollisionGroupId=1
end
end
}
and place the script inside “StarterPlayerScripts”
dutycall11
(SavageMode)
August 18, 2022, 9:34pm
#18
workspace is actually a shortcut for game.workspace, since it used constantly
Pretty sure you should use just “workspace”