Staff only proximity prompt

Thai Utility | Proximity Script

I created this on my phone so it may not work but I am positive my code is correct.

working on Group rank only version [Is2]

edit: ok here is the group version i was like bored and i checked this on a Lua checker and i think the local was the only problem so i fixed it. hopes up :point_up:

instructions:
you must have the item/tool in ServerStorage or Replicated storage.

make a proximity prompt however youd like to customize it and put it in your workspace item .

make a local script and put it under that item with the proximity prompt

I suggest to use Proximity not Proximity2


local Proximity = script.Parent
local Proximity2 = game:GetService(“Workspace”).item.ProximityPrompt

local ProtectedCall = pcall
local GroupId = 0 
local GroupRank = 0

Proximity.Triggered:Connect(function(Player)
	local Success, Result = ProtectedCall(function()
		return Player:GetRankInGroup(GroupId)
	end)
	
	if Success and
		 Result >= GroupRank then
	         local backpack = player.Backpack
	         local tool = game.ServerStorage.Cup -- make sure you have that item in serverstorage if not change to replicated storage and change “Cup” to your item mame.
                local IsCup = true
	
	         local toolClone = tool:Clone()
	
                 if IsCup == true then

	         toolClone.Parent = backpack
		end  -- this might be an extra end if script doesnt work delete it and try again
	end
end
end)
8 Likes

In the second script, you’re calling the LocalPlayer.

You can’t fetch the local player in server scripts. Only Local Scripts.

(Module Scripts included if they replicate to the client)

sorry i was testing this script for my friend .

Alright. This resource is nice. I like how you used Group Ranks, for this. I can name multiple ways though to do this though.

:slight_smile:

For instance, if you want to restrict the proximityprompt for certain players, you could this:


local proximityPrompt = script.Parent
local proximityPrompt2 = workspace.item.ProximityPrompt

local staffMembers = {“Roblox”}

— It would be better to use userids just in case the staff member changes their username.

local staffMemberUserIds = {1}


Proximity.Triggered:Connect(function(player: Player)
	local Success, Result = pcall(function()
		return table.find(staffMembers, player.Name) or table.find(staffMemberUserIds, player.UserId)
	end)
	
	if Success then
	— Do Stuff
         else
        — Do stuff
	end
end)

Your script isn’t wrong by the way. Its great. I just wanted to mention that there’s multiple ways to do this :slight_smile:

oh okay,thank you!! i’m just helping my friend rn because im im traveling and im bored!

1 Like

I forgot to mention that there’s a way to make a “Game Creator/Owner Only” Proximity Prompt.

Like this:

local proximityPrompt = script.Parent
local proximityPrompt2 = workspace.item.ProximityPrompt



Proximity.Triggered:Connect(function(player: Player)
	local Success, Result = pcall(function()
		return game.CreatorId == player.UserId
	end)
	
	if Success then
	— Do Stuff
    else
        — Do stuff
	end
end)
1 Like

This is amazing! I need to be honest, I personally will not be needing this, but other developers would find this extremely helpful, like some of my friends, for example. The ability to make staff only proximity prompts would be so useful in cafe games. My friends own cafe games, so I’ll recommend this extremely valuable resource to them! :slight_smile:

Thank you!

why not use pcall directly? i think creating a variable for it is unnessecary

you should also fix the formatting.

not a bad resource

why are you wrapping a function which is 100% guranteed to not error (unless its a localplace)

Proximity.Triggered:Connect(function(plr)
   if plr.UserId == game.CreatorId then
      --your code
   end
end)

Anything that could possibly error even in the any way should be wrapped in a pcall.

it dosent error, and dosent certainly error or not. pcalls were meant for stuff like http requests and not this

Let’s agree to disagree.

Should be in community tutorials im pretty sure.

Why should this be in #resources:community-tutorials? If you’re referring to the instructions shown on the OP, those are the instructions on how to use the script, not how the script works.

1 Like

I still think it should. It just seems like a tutorial.

Why?

Why not straight up disable it to those who do not have access to use the said ProximityPrompt?

1 Like

This does not work. It’s supposed to be if success and result then.

oh, i’ll check it out and fix it ig.

1 Like