So, I was in the middle of developing my game and I had a absurd idea to create a rank door with UI.
For those that don’t know what I’m on about:
I want a UI to pop up to a user that isn’t the correct rank to enter, and so you can purchase a gamepass to enter the door.
So, basically, detect when the door is touched (debounce to stop the game from going crazy), get the user rank, check user rank & then if the rank isn’t high enough charge a gamepass.
Something like this should work:
local Debounce = false
local GroupId = 1234567 --Put your groupId here
local GamepassId = 123467 -- Put your gamepassId here.
local MinRank = 1 --Put Min rank here
local Door = game.Workspace.Baseplate --Put the path to your door here.
local MarketPlaceServcice = game:GetService("MarketplaceService")
--Open Door Function
local function OpenDoor()
Door:Destroy()
end
--Detect Touch
script.Parent.Touched:Connect(function(User)
if Debounce == false then
Debounce = true
local UserRank = User:getRankInGroup(GroupId)
if UserRank <= MinRank then
if MarketPlaceServcice:UserOwnsGamePassAsync(User, GamepassId) == false then
MarketPlaceServcice:PromptGamePassPurchase(User, GamepassId)
else
OpenDoor()
end
else
OpenDoor()
end
end
end)
It’s not the most efficient script nor has it been tested, but it should do the trick.
local Debounce = false
local GroupId = 1234567 --Put your groupId here
local GamepassId = 123467 -- Put your gamepassId here.
local MinRank = 1 --Put Min rank here
local Door = game.Workspace.Part --Put the path to your door here.
local MarketPlaceServcice = game:GetService("MarketplaceService")
--Open Door Function
local function OpenDoor()
Door:Destroy()
end
--Detect Touch
script.Parent.Touched:Connect(function(User)
if Debounce == false then
Debounce = true
local partParent = User.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local UserRank = User:getRankInGroup(GroupId)
if UserRank <= MinRank then
if MarketPlaceServcice:UserOwnsGamePassAsync(User, GamepassId) == false then
MarketPlaceServcice:PromptGamePassPurchase(User, GamepassId)
else
OpenDoor()
end
else
OpenDoor()
end
end
end
end)