So I made a LocalScript to make parts be transparent when they are close to you. The problem is that the parts that are registered here always say they are 0 studs away from the character. Is there a way to fix this?
Local Script in StarterPlayerScripts:
local RunService = game:GetService("RunService")
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local FadeObj = {}
for i, obj in ipairs(workspace:GetDescendants()) do
if obj:IsA("ObjectValue") and obj.Name == "_Distance" then
table.insert(FadeObj, 1, obj.Parent)
end
end
for i, part in ipairs(FadeObj) do
local plrDistance = Player:DistanceFromCharacter(part.Position)
function Update()
print(plrDistance)
if plrDistance < 10 then
part.Transparency = 1
else
part.Transparency = 0
end
end
RunService.Heartbeat:Connect(Update)
end