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.
Any help would be appreciated, thanks!
So, when a player touches a door, the gamepass purchase UI shows up?
Indeed. (character thing)
Noah
4
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.
2 Likes
Should this script go in StarterGUI, or ServerScriptService?
I’ll test it in the door, StarterGUI and the. SSS,
ok, thank you, remove the 20 characters ;(
I did that, but I get greeted with this error.
Noah
11
I haven’t tested it, minor error:
script.Parent.Touched:Connect(function(User)
should be
Door.Touched:Connect(function(User)
Thank you!!
Actually remove the 20 character thing-
Lol, these errors love your script
@Noah
Noah
14
Try this updated code
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)
Thanks, I’ll probably make some modifications to the script depending on how lazy I am
system
Closed
16
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.