Group rank only Proximity Prompt

Hiya!

My question is how can I make it so the proximity prompt work/show up only if the person is in my group, a specific rank or above?

I have tried different way, but couldn’t get it to work. Sometimes the door just opened and never closed. Or it just did not work at all.

Code
local TweenService = game:GetService("TweenService")
local door = script.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()

local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
	CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-100),0)--Change 100 to whatever value. Range of swing.
})

local doorCFrameClosed = TweenService:Create(doorHinge, doorOpen, {
	CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0),0)--Change 100 to whatever value. Range of swing.
})

local ProximityPrompt = script.Parent.ProximityPrompt
local PromptVanish = ProximityPrompt.Enabled == false
local PromptAppear = ProximityPrompt.Enabled == true

ProximityPrompt.Triggered:Connect(function()
	doorCFrame:Play()
	ProximityPrompt.Enabled = false
	script.Parent.Open:Play()--rbxassetid://192416578
	wait(3)--Door Stays Open this long
	doorCFrameClosed:Play()
	ProximityPrompt.Enabled = true
	wait(1)
	script.Parent.Close:Play()

end)

You can use GetRankInGroup to check what rank he is, and make sure to use pcalls .

Here is a raw example:

[Look for the last comment there]

2 Likes