How to fix my proximity prompt?

  1. What do you want to achieve? Keep it simple and clear!
    So basically, I have a proximity prompt in the players UpperTorso. I want to make my proximity prompt not show if there is a wall between the 2 players (which is easy, you turn requireslineofsight to true, but when you do that the proximity prompt doesn’t show if the player is next to them because of the other parts in the player) and I want it to show if the player is next to them, but it doesn’t because requires line of sight = true so that you can’t see it through the wall.

This is what it looks like when there’s a wall between the 2 players, which is good because it doesn’t show:

This is what it looks like in workspace :

Also, whats weird is the player who has the proximity prompt inside of them can only see it, btw i did add the proximity prompt into the player on the server, so technically it should show for both players :

These are the properties of the proximity Prompt:

And this is what it looks like when a player is next to them, the proximity prompt doesn’t appear :

  1. What is the issue? Include screenshots / videos if possible!
    The proximity prompt doesn’t show when the player is right next to them.

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried YT and Devforum.

Should I try adding a part into the player, unanchor it, weld it to the uppertorso and make it big, and then put the proximity prompt in there?

So basically what I’m trying to achieve is that the proximity prompt can’t be seen if there is a wall in the way and if the player moves around the wall and to the other player the proximity prompt can be seen. But if the player moves around the wall and to the other player the proximity prompt still can’t be seen because of all the characters parts in the way.

Disable the property requires line of sight

2 Likes

Yes, but then the other player will be able to see the proximity prompt through the wall which i dont want

add an attachment inside the players torse, change the CFrame so its behind the torso a little, and add the proximity prompt in there. Should help… I think!

1 Like

I did that already but then the proximity prompt can’t be seen from the front and the sides, which i kinda need

You could disable the proximity prompt for the other player so they can’t interact with it?

1 Like

wdym? Disable it when its behind a wall?

Not sure how efficient the solution would be, but yes, you could have some sort of RayCasting to determine whether a wall is behind the player and disable the prompt if the condition is met.

1 Like

Ok, so how can i detect if there is an object in the way? (I don’t really know much about raycasting)

I’m not much of a teacher, and to be honest, raycasting is not a strong suit of mine, however, I’m sure the Documentation provides examples of use cases of raycasting.

Link: Raycasting | Documentation - Roblox Creator Hub

1 Like

Thank you

Maximum Character limittt

1 Like

Almost done, if it works, ill mark urs as the solution

THANKS SO MUCH (i googled a few tutorials on devforum and found exactly what i needed)

Hey uh, i got a problem, if the player is behind a wall the ray prints out that a part is in the way, which is good, but if the player turns around facing the wall, it glitches and thinks nothing is in the way and enables the proximity prompt (I filtered out both players characters btw), here it is :

And if the player turns around facing the opposite way the script works as it should :

This is my script (its a local script btw in a tool)

local Equipped = false
local player = game.Players.LocalPlayer

script.Parent.Equipped:Connect(function()
	Equipped = true
	
	while Equipped do
		wait()
		for i,v in pairs(game.Workspace:GetDescendants()) do
			if v.Parent:FindFirstChild("Humanoid") and v.Name == "UpperTorso" and v:FindFirstChild("ArrestPrompt") and v.Parent:FindFirstChild("Arrested") then
				local MAX_DISTANCE = 5
				local rayParams = RaycastParams.new()
				rayParams.FilterType = Enum.RaycastFilterType.Blacklist
				rayParams.FilterDescendantsInstances = {player.Character, v.Parent}
				
				local ray = workspace:Raycast(player.Character.UpperTorso.Position, v.CFrame.LookVector * MAX_DISTANCE, rayParams)
				
				if (ray ~= nil) then
					print("PART IS IN THE WAY")
					v:FindFirstChild("ArrestPrompt").Enabled = false
				else
					print("NO PART IS IN THE WAY")
					if v.Parent.Arrested.Value == false and v.Parent.Humanoid.Health > 0 then
						v:FindFirstChild("ArrestPrompt").Enabled = true
						local ArrestedPlayer = v.Parent
						script.Parent.EquippedEvent:FireServer(ArrestedPlayer)
					else
						v:FindFirstChild("ArrestPrompt").Enabled = false
					end
				end
			end
		end
	end
end)