So what i want is when a object comes closer to you, a noise sound will increase volume.
I want the sound increase when the magnitude is equal or lower than 50.
LocalScript:
local plr = game.Players.LocalPlayer
local image = script.Parent.Static
local noise = script:WaitForChild("Static")
game:GetService("RunService").Heartbeat:connect(function()
local mag = (workspace["Red Killer"].HumanoidRootPart.Position - plr.Character.HumanoidRootPart.Position).Magnitude
if plr.Character and plr.Character:FindFirstChild('HumanoidRootPart') and mag <= 50 then
image.ImageTransparency = (mag*2)/100
noise.Volume = -- I don't know!!
end
end)
local players = game:GetService("Players")
local runService = game:GetService("RunService")
local plr = players.LocalPlayer
local image = script.Parent.Static
local noise = script:WaitForChild("Static")
runService.Heartbeat:Connect(function()
local mag = (workspace["Red Killer"].HumanoidRootPart.Position - plr.Character.HumanoidRootPart.Position).Magnitude
if plr.Character and plr.Character:FindFirstChild('HumanoidRootPart') and mag <= 50 then
image.ImageTransparency = (mag * 2) / 100
noise.Volume = (50 - mag) * 0.01 + 0.5
end
end)
local players = game:GetService("Players")
local runService = game:GetService("RunService")
local plr = players.LocalPlayer
local image = script.Parent.Static
local noise = script:WaitForChild("Static")
runService.Heartbeat:Connect(function()
local mag = (workspace["Red Killer"].HumanoidRootPart.Position - plr.Character.HumanoidRootPart.Position).Magnitude
if plr.Character and plr.Character:FindFirstChild('HumanoidRootPart') then
image.ImageTransparency = if mag <= 50 then (mag * 2) / 100 else 1
noise.Volume = if mag <= 50 then (50 - mag) * 0.02 else 0
end
end)