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

Why does my CollisionGroup not work on the first person in a server?

Asked by
Joshument 110
5 years ago

This is supposed to be a door for a gamepass (lounge). If a player owns the gamepass, they will be able to go through unless they are the first person to join. They can't walk through the wall.

local gamepassid1 = 5645201 --replace 0 with your gamepass id--
local gamepassid2 = 5645200 --replace 0 with your gamepass id--

--Script--

local part = script.Parent
local PhysicsService = game:GetService("PhysicsService")
local MarketplaceService = game:GetService("MarketplaceService")

PhysicsService:CreateCollisionGroup("GamepassHolders")
PhysicsService:CollisionGroupSetCollidable("GamepassHolders", "GamepassHolders", false)

PhysicsService:SetPartCollisionGroup(part, "GamepassHolders")

game.Players.PlayerAdded:Connect(function(player)
    local uid = player.UserId
    if MarketplaceService:UserOwnsGamePassAsync(uid, gamepassid1) or MarketplaceService:UserOwnsGamePassAsync(uid, gamepassid2) then
        player.CharacterAdded:Connect(function(character)
            for i, v in pairs(character:GetDescendants()) do
                if v:IsA("BasePart") then
                    PhysicsService:SetPartCollisionGroup(v, "GamepassHolders")
                end
            end
        end)
    end
end)
0
Did you make this script or get it from the toolbox? User#16405 0 — 5y
0
I made it Joshument 110 — 5y
0
100% sure he made it judging by his scripting abilities. Mr_Pure 129 — 5y
0
Either of you able to answer this? Joshument 110 — 5y

Answer this question