Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[ANSERWED] Trying to make group door but, script wont work for the door?

local groupID = 11879197
local RankToEnter = 190
local Garage = script.Parent

game.Players.PlayerAdded:Connect(function(player)
	if player:GetRankInGroup(groupID) >= RankToEnter then
	local function ifTouched(GarageFunction)
	if GarageFunction.parent:FindFirstChild('Humanoid') then
		Garage.Transparency = .5
		Garage.CanCollide = false
		wait(5)
		Garage.Transparency = 0
		Garage.CanCollide = true
	else
		print('failed to open garage FORTNITE1_01')
			end
		end
	end
end)

This script is not working!! Help me!

I'm trying to make a group door the will change the cancolide and transparency factor of the door, but the script won't work?

1 answer

✓ Accepted answer

You can achieve this with collision service by creating a collusion group for the "Garage" and one for the players with the rank like this:


local groupID = 11879197
local RankToEnter = 190
local Garage = script.Parent


local PhysicsService = game:GetService("PhysicsService")


local playerWithRankGroup = "PlayerWithRankGroup";
local garageGroup = "garageGroup";

PhysicsService:CreateCollisionGroup(playerWithRankGroup)
PhysicsService:CreateCollisionGroup(garageGroup)


PhysicsService:SetPartCollisionGroup(Garage, garageGroup)
function setPlayerGroup(char)
	for i,v in pairs(char:GetDescendants()) do
		if (v:IsA("BasePart")) then
			PhysicsService:SetPartCollisionGroup(v, playerWithRankGroup);
		end
	end
end





game.Players.PlayerAdded:Connect(function(player)
	if player:GetRankInGroup(groupID) >= RankToEnter then
		local character = player.Character or player.CharacterAdded:Wait()
		
		setPlayerGroup(character)
		player.CharacterAdded:Connect(function()
			character = player.Character
			if character then
				setPlayerGroup(character)
			end
		end)
	end
end)









PhysicsService:CollisionGroupSetCollidable(playerWithRankGroup, garageGroup, false)

This discussion is preserved as it was. New answers, comments, and votes are closed.