Hey there, I have been struggling for a few days trying to get an effect for an indicator in my game where the image will get bigger as you get near it and smaller as you go away (inside certain range).
I sort of managed to get a similar effect by saving the distance of the rootpart and the part with a delay, and then just adding or substracting 0.1 to it’s size, but the result is innacurate sometimes, buggy and easy to break.
Video:
Bug:
Attempt:
RunService.Heartbeat:Connect(function()
local Distance = (RootPart.Position - TestPart.Position).Magnitude
if Distance <= MaxRange then
--Way to determine if thing is bigger or smaller
if DelayBool == false then
DelayBool = true
LastDistance = Distance
delay(0.05, function()
DelayBool = false
end)
end
--Clone
if Clone == nil then
Clone = BillBoard:Clone()
BillBoard.Size = MinSize
Clone.Enabled = true
Clone.Parent = TestPart
Clone.Adornee = TestPart
end
--Resize
if Distance <= MaxRange and Distance > LastDistance then --Make smaller
if Clone ~= nil then --Check it exists
if Clone.Size.Y.Scale > MinSize.Y.Scale then --Ensure it's not smaller than 0
Clone.Size = Clone.Size + UDim2.new(-0.1, 0, -0.1, 0)
end
end
elseif Distance <= MaxRange and Distance < LastDistance then --Make bigger
if Clone ~= nil then --Check it exists
if Clone.Size.Y.Scale < MaxSize.Y.Scale then --Ensure it's not bigger than it's og size
Clone.Size = Clone.Size + UDim2.new(0.1, 0, 0.1, 0)
end
end
end
else
--Destroy
if Clone ~= nil then
Clone:Destroy()
Clone = nil
end
end
end)
All I want to know is if there is a more accurate or easy way to achieve this effect without it breaking. I have a few other things i’d like to do similar to this like dynamically changing the walkspeed of the player for wind effects and stuff like that so figuring this out would be really helpful.