Else running when not supposed to

Hello,

My else is running when it’s not supposed to. I’m trying to make a car spawner but it half works and half broken.
Here is the code
I commented the sections where the bug is.

for _, v in pairs(script.Parent:GetChildren()) do
	if v.ClassName ~= "Script" then
		v.ClickDetector.MouseClick:Connect(function(plr)
			for _, obj in pairs(game.Workspace:GetChildren()) do
				if obj.Name == v.CarName.Value then
					if obj:FindFirstChild("Car") then
						--Starts here
						--Runs while the else is commented
						if plr:DistanceFromCharacter(obj.Car.Wheels.RR.Position) <= 15 then
							print("here")
							obj:Destroy()
							local cloned_car = game.ServerStorage.CarBackups[obj.Name]:Clone()
							cloned_car.Parent = game.Workspace
						else
							print("not here")
							local cloned_car = game.ServerStorage.CarBackups[obj.Name]:Clone()
							cloned_car.Parent = game.Workspace
							break
						--ends here
						end
					end
				end 
			end
		end)
	end
end

The if statement I commented near runs when the else and it’s code inside is commented. For some reason the else is running when it’s not supposed to.
If you guys got any idea please reply, also if there is a way to improve my code reply aswell. I’m trying to learn code optimization.

Thanks!

I added math.floor which fixed the issue finally. :smiley:

math.floor(plr:DistanceFromCharacter(obj.Car.Wheels.RR.Position)) <= 15

Thank you to the people who even tried to reply but failed and did not send. >:(
:slight_smile: