I have this system where a player can create a “Host match”, which another player can join by interacting with the proximity prompt.
However, it seems that the prompt shows up for the player who hosts it as well, which I don’t want.
(host view)
Is there a way I can hide this from the player that started the host match?
Code:
local function addProximityPrompt(player)
local promptAttachment = Instance.new("Attachment")
local prompt = Instance.new("ProximityPrompt")
promptAttachment.Parent = player.Character.UpperTorso
prompt.ActionText = "Join Match"
prompt.ObjectText = player.Name
prompt.RequiresLineOfSight = false
prompt.Parent = promptAttachment
end
From a LocalScript just destroy the player’s own proximity prompt:
local Players = game:GetService("Players")
local client = Players.LocalPlayer
client.CharacterAdded:Connect(function(character: Model)
character.DescendantAdded:Connect(function(descendant: Instance)
if descendant:IsA("ProximityPrompt") then
descendant:Destroy()
end
end)
end)
What if you tried just disabling the prompt? I’m certain that there is an Enabled property for proximity prompts (I’m not 100% sure because I never used proximity prompts), so try setting it to false instead of destroying the prompt.
local Players = game:GetService("Players")
local client = Players.LocalPlayer
local function addProximityPrompt(player)
-- by the way it isn't necessary to parent a prompt to an attachment if you won't change the offset :p
local promptAttachment = Instance.new("Attachment")
local prompt = Instance.new("ProximityPrompt")
promptAttachment.Parent = player.Character.UpperTorso
prompt.ActionText = "Join Match"
prompt.ObjectText = player.Name
prompt.RequiresLineOfSight = false
prompt.Parent = promptAttachment
end
Players.PlayerAdded:Connect(addProximityPrompt) -- add new prompts for new players
for _, player in ipairs(Players:GetPlayers()) do
if player ~= client then
addProximityPrompt(player)
end
end