How to add proximity prompt to player?

So i want to make a feature that will put a prompt on the player’s root part but i cant figure it out i saw one script but i can see my own prompt. How do i make it so that only other player can see and interact with my prompt? I tried making it two separate scripts one server that creates the prompt and one in client for the gui visibility but it still doesnt work. Do i need to make a custom one?

4 Likes

You can use the players added event, in that event you would create a proximity prompt instance, parent it to the humanoidrootpart or primarypart, and that should be it. This should be done in a server sided script.

See this for reference on players added event: Players | Documentation - Roblox Creator Hub

1 Like

yeah ive done that but the player themselves can see their own prompt. or am i doing something wrong

1 Like

Well, then you need a client sided script to disable a players own proximity prompt. This will disable it client sided, for their own prompt, which should be a solution

I’ve also tried doing that but the prompt is still showing for me.

1 Like

put a local script under the prompt being placed under the player, the script can be like so:

script.Parent.Enabled = false
1 Like

How do i do that? the script is being made from a script. Do i just make a prompt, put it in replicated storage then clone it?

Edit: So far i did this but it doesnt do anything. previously i just parented it to the player but it wasnt showing even if i disabled the script that disables the prompt. eve

local Players = game:GetService("Players")
local PPS = game:GetService("ProximityPromptService")
local RS = game:WaitForChild("ReplicatedStorage")

local function createPrompt(plr)
	local prompt = RS:WaitForChild("Prompt"):Clone()
	
	prompt.Parent = plr:WaitForChild("HumanoidRootPart")
end

Players.PlayerAdded:Connect(createPrompt)

nvm im stupid but still it doesnt work with the script you gave when its off it does the same from my previous script which shows the player their own prompt but when its on no one can see the prompt even other player’s prompts

heres the code so far.

local Players = game:GetService("Players")
local RS = game:WaitForChild("ReplicatedStorage")

local function createPrompt(plr)
	local prompt = RS:WaitForChild("Prompt"):Clone()
	
	local char = plr.Character or plr.CharacterAdded:Wait()
	
	prompt.Parent = char:WaitForChild("HumanoidRootPart")
end

Players.PlayerAdded:Connect(createPrompt)
1 Like

On the server every time a character is added run a loop like this…

for i, v in pairs(Players:GetPlayers()) do
      if v.Name ~= Player.Name then
             RemoteEvent:FireClient(v, arg1, arg2)
      end
end
1 Like

Whats arg1 and arg2 for? sorry im quite new to scripting

1 Like

Think of it as a variable being sent from the server to the client.

1 Like

Yeah but i dont have a client script except for the one Kaiden said parented to the prompt. Do i put the code on .OnClientEvent?

Edit: Tried doing it. It kinda works problem is the first player that joined does see the prompt on the other player but the second player however sees his own

Server:

local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")

local function createPrompt(plr)
	local prompt = RS:WaitForChild("Prompt"):Clone()

	local char = plr.Character or plr.CharacterAdded:Wait()

	prompt.Parent = char:WaitForChild("HumanoidRootPart")

	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= plr then
			RemoteEvent:FireClient(player)
		end
	end
end

Players.PlayerAdded:Connect(createPrompt)

Client (The one parented to the premade prompt in replicated storage):

local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")

RemoteEvent.OnClientEvent:Connect(function()
	script.Parent.Enabled = false
end)

Could you send your code and what your explorer looks like?

1 Like

Well First, you might want to parent the client and prompt with the server script

Let the server script detect when a character is added and send a remote event

Place the prompt parented to the client script
place the client script in startercharacter

When the client script receives the event (Which will have the character of where the prompt needs to go) you will easily place it there

1 Like

I didnt quite understant this part “Place the prompt parented to the client script
place the client script in startercharacter”

so just to make it clear I dont need to change anything in the prompt. I make a client script in starter character right? cause thats what i did

1 Like

yes so the prompt is parented to the client script and the client script in startercharacterscripts

1 Like

Im sorry im not getting that which client script? cause i had a client script parented to the prompt. Do i reverse that? parent the prompt to the client script instead or is the client script youre talking about is a new one that i need to make im so confused

Just a client script to handle receiving the event