Hello, I’m trying to make an effect that gets more intense the closer you are to a part.
I have a few parameters set to make the effect begin at a low level and gradually scale up to another level of intensity based on the distance (Magnitude)
This is my code:
(Placeholder for testing)
local Player = game.Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local Part = workspace:WaitForChild("Part")
local RunService = game:GetService("RunService")
local MaxDistance = 20
local MinDistance = 5
RunService.Heartbeat:Connect(function(t)
local Intensity = (math.clamp((HRP.Position-Part.Position).Magnitude,MinDistance,MaxDistance)-MinDistance) / (MaxDistance-MinDistance)
print(1-Intensity)
end)
What I want it to do is scale the Intensity value on an exponential graph, like the following example shown in this video (at timestamp 0:58):
I get what you mean by using TweenService, but it’s not what I’m referring to. I want the Intensity to scale up exponentially from MinDistance to MaxDistance.