I want to verify if the player is under 5 stud from the part1!

Why this not work ?

if player:DistanceFromCharacter(part1.Position) <= 5 then

please help me .

These is indeed a better way to calculate where a person’s character is.

Juts use ProximityPrompt:PromptShown.

1 Like

hum can you help me whis that too because i want to verify if the player is under 5 stud from the part1

1 Like

Indeed, I can.

You can check when the Prompt is shown, and set the prompt show distance to 5.

for example code:

script.Parent.PromptShown:Connect(function()
       -- do what u want when the player is within range here
end)

What doesn’t work about this script? Does it throw an error or not calculate the distance correctly?

player:DistanceFromCharacter gives the distance from the Player to the Character, not from the character to a random part.

Look at my previous post.

30letters

how to set the prompt show distance i do a local promptshow = 5
or what ?

In the prompt properties.

had to throw soem words here to post

that just dont work no error
is show

The API documentation says that DistanceFromCharacter gives the distance between the character’s head and a Vector3.

yes that why i do that but that wont work

Sorry, I thought that it did something else.

ok i try it wait
letters lol i dont know letttterrrsssssssssssssssssssssssss

Assuming you’ve defined part1 correctly, it should work just fine. As a test, try setting 5 to a larger number and see what you get since 5 studs is pretty small. We may need to see more of your script to help you beyond that.

This works for me. I just tossed it into a loop to test. (Worked Server & Local)

Edit with the correct variables…

local part1 = workspace.part1

while wait(1) do
		if player:DistanceFromCharacter(part1.Position) <= 5 then
			print(player:DistanceFromCharacter(part1.Position))
			part1.BrickColor = BrickColor.Green()
		else
			print(player:DistanceFromCharacter(part1.Position))
			part1.BrickColor = BrickColor.Red()
		end
	end

worked? or not…

spam here cuz 30letters

i dont know how to do it did i put the proximityprompt inside my model