View difference between Paste ID: F4VUVWFs and r8V31N1F
SHOW: | | - or go back to the newest paste.
1
local vipDoor = workspace:WaitForChild("VIPDoor")
2
local vipId = 8833520
3
4
local cafeWorkerDoor = workspace:WaitForChild("CafeWorkerDoor")
5
local cafeWorkerId = 8833515
6
7
local marketplaceService = game:GetService("MarketplaceService")
8
local physicsService = game:GetService("PhysicsService")
9
10
physicsService:CreateCollisionGroup("VIPPlayers")
11
physicsService:CreateCollisionGroup("VIPDoor")
12
physicsService:CollisionGroupSetCollidable("VIPPlayers", "VIPDoor", false)
13
14
physicsService:CreateCollisionGroup("CafeWorkers")
15
physicsService:CreateCollisionGroup("CafeWorkerDoor")
16
physicsService:CollisionGroupSetCollidable("CafeWorkers", "CafeWorkerDoor", false)
17
18
physicsService:CreateCollisionGroup("CafeWorkerAndVIP")
19
physicsService:CollisionGroupSetCollidable("CafeWorkerAndVIP", "VIPDoor", false)
20
physicsService:CollisionGroupSetCollidable("CafeWorkerAndVIP", "CafeWorkerDoor", false)
21
22
physicsService:SetPartCollisionGroup(vipDoor, "VIPDoor")
23
physicsService:SetPartCollisionGroup(cafeWorkerDoor, "CafeWorkerDoor")
24
25
local function addToGroup(character, group)
26
	for i, descendant in ipairs(character:GetDescendants()) do
27
		if descendant:IsA("BasePart") then
28
			physicsService:SetPartCollisionGroup(descendant, group)
29
		end
30
	end
31
end
32
33
game.Players.PlayerAdded:Connect(function(player)
34
	player.CharacterAppearanceLoaded:Connect(function(character)
35
		-- Check for VIP GamePass
36
		local success, result = pcall(function()
37
			return marketplaceService:UserOwnsGamePassAsync(player.UserId, vipId)
38
		end)
39
		if not success then print(result) end
40
		if success and result then
41
			addToGroup(character, "VIPPlayers")
42
		end
43
		
44
		-- Check for Premium Cafe Worker GamePass
45
		local success2, result2 = pcall(function()
46
			return marketplaceService:UserOwnsGamePassAsync(player.UserId, cafeWorkerId)
47
		end)
48
		if not success2 then print(result2) end
49
		if success2 and result2 then
50
			addToGroup(character, "CafeWorkers")
51
		end
52
		
53
		if success and result and success2 and result2 then
54
			addToGroup(character, "CafeWorkerAndVIP")
55
		end
56
	end)
57
end)
58
59
local function promptGamepassPurchase(player, id)
60
	local success, result = pcall(function()
61
		return marketplaceService:UserOwnsGamePassAsync(player.UserId, id)
62
	end)
63
	if not success then print(result) end
64
	if success and not result then
65
		marketplaceService:PromptGamePassPurchase(player, id)
66
	end
67
end
68
69
vipDoor.Touched:Connect(function(hit)
70
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
71
	if player then
72
		promptGamepassPurchase(player, vipId)
73
	end
74
end)
75
76
cafeWorkerDoor.Touched:Connect(function(hit)
77
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
78
	if player then
79
		promptGamepassPurchase(player, cafeWorkerId)
80
	end
81
end)
82
83
marketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamepassId, wasPurchased)
84
	if gamepassId == vipId then
85
		if wasPurchased then
86
			local success, result = pcall(function()
87
				return marketplaceService:UserOwnsGamePassAsync(player.UserId, cafeWorkerId)
88
			end)
89
			if not success then print(result) end
90
			if success and result then
91
				addToGroup(player.Character, "CafeWorkerAndVIP")
92
			else
93
				addToGroup(player.Character, "VIPPlayers")
94
			end
95
		end
96
	elseif gamepassId == cafeWorkerId then
97
		if wasPurchased then
98
			local success, result = pcall(function()
99
				return marketplaceService:UserOwnsGamePassAsync(player.UserId, vipId)
100
			end)
101
			if not success then print(result) end
102
			if success and result then
103
				addToGroup(player.Character, "CafeWorkerAndVIP")
104
			else
105
				addToGroup(player.Character, "CafeWorkers")
106
			end
107
		end
108
	end
109
end)