hello there im making a door only openable by a member in a certain group rank by a proximity prompt any help? here is the code
local Hinge = script.Parent.PrimaryPart
local opened = false
local Promt = script.Parent:WaitForChild("ProximityPrompt")
local groupID = 9423809
local player = game:GetService("Players")
local playerRank = player:GetRankInGroup(groupID)
if playerRank > 3 then
function OpenDoor()
if opened == false then
opened = true
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
wait()
end
else
opened = false
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
wait()
end
end
end
end
Promt.Triggered:Connect(function(Players)
OpenDoor()
end)
script.Parent.Door.ProxomityPrompt.Triggered:Connect(OpenDoor)
Because Triggered returns the player who triggered the prompt, you can simply use the Function of player instances, GetRankInGroup, giving it the Group id of your group and comparing it to the number corressponding to the rank in your group.
From what I can see in your code, you only need the thing inside of the triggered event, the Players service doesn’t have this event
Sometihng like this is what is needed from what I can see
Promt.Triggered:Connect(function(Player)
if Player:GetRankInGroup(groupID) > 3 then
return
end
OpenDoor()
end)
Full code would be this
local Hinge = script.Parent.PrimaryPart
local opened = false
local Promt = script.Parent:WaitForChild("ProximityPrompt")
local groupID = 9423809
function OpenDoor()
if opened == false then
opened = true
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
wait()
end
else
opened = false
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
wait()
end
end
end
Promt.Triggered:Connect(function(Player)
if Player:GetRankInGroup(groupID) < 3 then
return
end
OpenDoor()
end)
script.Parent.Door.ProxomityPrompt.Triggered:Connect(OpenDoor)
@ThattSav Sorry about that, didn’t notice the small typo! Glad it worked though!