Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Applying Collision Groups to Player?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make an unanchored brick, stored in ServerStorage, uncollidable with the player. If I turn CanCollide in the brick off, it'll just fall through the ground, so I need to use collision groups. The script I have right now doesn't seem to work, and I'm not sure why.

local PhysicsService = game:GetService("PhysicsService")

local bell = "Bell"
local characters = "Characters"

PhysicsService:CreateCollisionGroup(bell)
PhysicsService:CreateCollisionGroup(characters)

PhysicsService:SetPartCollisionGroup(game.ReplicatedStorage.LooseBell, bell)
PhysicsService:CollisionGroupSetCollidable(bell, characters, false)
PhysicsService:CollisionGroupSetCollidable(characters, bell, false)


local function onCharacterAdded(character)
    PhysicsService:SetPartCollisionGroup(character.Torso, characters)
    PhysicsService:SetPartCollisionGroup(character.Head, characters)

end

function playerAdded(plr)
    plr.CharacterAdded:Connect(onCharacterAdded)
end

game.Players.PlayerAdded:connect(playerAdded)
0
Is this your full script? I don't know much about collision groups yet, but If it is the problem might be that you aren't connecting the playerAdded function to the game.Players.PlayerAdded event. aquathorn321 858 — 5y
0
Whoops! Yeah, I forgot to include the one line at the bottom that did that in the post. It was always there, though. Edited now! SuperJumpman12 43 — 5y

Answer this question