I'm kind of new to scripting and i wanted to make a detector that detects how close a player is.

When i got this error; "Expected identifier while parsing expression, got >"?

Error is on line 14, where i do the "< lowest" thing <3

local Configurations = {
["Too close"] = 10,
["Close"] = 20,
["Neutral"] = 30,
["Far"] = 40,
["Too far"] = 50,
}

while wait(0.5) do
	
for k, v in pairs(Configurations) do
	local lowest = v - 10
	
	if (HumanoidRootPart.Position - Part.Position).Magnitude <= v and < lowest then
		
		print("Player is ", k)
	end
end
end

Help appreciated!

5 comments

0

You can't evaluate two expressions as a trailing statement. You'll need to compare lowest to the magnitude again.

0

Oh, can you write your comment as an answer so i can accept.

0

That's fine, no answer is needed in such a short fix.

0

Simply store the distance calculated into a variable: local Magnitude = ... then: if (Magnitude <= v) and (Magnitude < lowest).

0

Thank you sir!