Hello!, so, my car idle sound just disappears when car is idle, after a little bit of time,
It start working only when i again get into car.
local FE = workspace.FilteringEnabled
local car = script.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])
local on = 0
script:WaitForChild("Idle")
if not FE then
for i,v in pairs(car.DriveSeat:GetChildren()) do
for _,a in pairs(script:GetChildren()) do
if v.Name==a.Name then v:Stop() wait() v:Destroy() end
end
end
for i,v in pairs(script:GetChildren()) do
v.Parent=car.DriveSeat
end
car.DriveSeat.Idle:Play()
while wait() do
local _RPM = script.Parent.Values.RPM.Value
if not script.Parent.IsOn.Value then on=math.max(on-.015,0) else on=1 end
car.DriveSeat.Idle.Pitch = (car.DriveSeat.Idle.SetPitch.Value - car.DriveSeat.Idle.SetRev.Value*_RPM/_Tune.Redline)*on^2
end
else
local handler = car.AC6_FE_Sounds
handler:FireServer("newSound","Idle",car.DriveSeat,script.Idle.SoundId,0,true)
handler:FireServer("playSound","Idle")
local pitch=0
while wait() do
local _RPM = script.Parent.Values.RPM.Value
if not script.Parent.IsOn.Value then on=math.max(on-.015,0) else on=1 end
pitch = (script.Idle.SetPitch.Value - script.Idle.SetRev.Value*_RPM/_Tune.Redline)*on^2
handler:FireServer("updateSound","Idle",script.Idle.SoundId,pitch,script.Idle.Volume)
end
end
I will appreciate your help!
Also here AC6_FE_SOUND handler:
local Sounds = {}
local F = {}
F.newSound = function(name,par,id,pitch,loop)
for i,v in pairs(Sounds) do
if i==name then
v:Stop()
v:Destroy()
end
end
local sn = Instance.new("Sound",par)
sn.Name = name
sn.SoundId = id
sn.Pitch = pitch
sn.Looped = loop
sn.AncestryChanged:connect(function(child,parent) print(parent) end)
Sounds[name]=sn
end
F.updateSound = function(sound,id,pit,vol)
local sn = Sounds[sound]
if id~=sn.SoundId then sn.SoundId = id end
if pit~=sn.Pitch then sn.Pitch = pit end
end
F.pauseSound = function(sound)
Sounds[sound]:Pause()
end
F.stopSound = function(sound)
Sounds[sound]:Stop()
end
F.removeSound = function(sound)
Sounds[sound]:Stop()
Sounds[sound]:Destroy()
Sounds[sound]=nil
end
script.Parent.OnServerEvent:connect(function(pl,Fnc,...)
F[Fnc](...)
end)