Hi! I’m doing a system for my game. The system is:
There’s a bass hit animations like: Dab
and this animations playing to Music/Sound bass and it uses Playbackloudness for doing bass hit animation. So i wanted to make animations play/stop smoothier and i used “RunService.RenderStepped:Connect(function()” everything is okay but after a while, script causing to low FPS
Here script:
-For Function
function BassHit()
RunService.RenderStepped:Connect(function()
if LocalPlayer:FindFirstChild("PlayerFolder") and LocalPlayer.PlayerFolder:FindFirstChild("SelectedBassHit") and LocalPlayer.PlayerFolder.SelectedBassHit.Value == "Dab" then
Dab:Play()
Dab:AdjustSpeed(script.TweenValue2.Value)
Dab:AdjustWeight(script.TweenValue2.Value)
BassHitt = true
end
if LocalPlayer:FindFirstChild("PlayerFolder") and LocalPlayer.PlayerFolder:FindFirstChild("SelectedBassHit") and LocalPlayer.PlayerFolder.SelectedBassHit.Value == "T-Pose" then
TPose:Play()
TPose:AdjustSpeed(script.TweenValue2.Value)
TPose:AdjustWeight(script.TweenValue2.Value)
end
if LocalPlayer:FindFirstChild("PlayerFolder") and LocalPlayer.PlayerFolder:FindFirstChild("SelectedBassHit") and LocalPlayer.PlayerFolder.SelectedBassHit.Value == "Thrust" then
Thrust:Play()
Thrust:AdjustSpeed(script.TweenValue2.Value)
Thrust:AdjustWeight(script.TweenValue2.Value)
end
end)
end
Starts function:
- Also this one uses “RunService.RenderStepped:Connect(function()” too
if Track.PlaybackLoudness >= Track:WaitForChild("AmountValue").Value then
local Tween = TweenService:Create(script.TweenValue2, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Value = Track.PlaybackLoudness * 0.009}):Play()
BassHit()
elseif Track.PlaybackLoudness < Track:WaitForChild("AmountValue").Value then
if Dab.IsPlaying == true then
Dab:Stop()
local Tween = TweenService:Create(script.TweenValue2, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Value = 0}):Play()
end
if TPose.IsPlaying == true then
TPose:Stop()
local Tween = TweenService:Create(script.TweenValue2, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Value = 0}):Play()
end
if Thrust.IsPlaying == true then
Thrust:Stop()
local Tween = TweenService:Create(script.TweenValue2, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Value = 0}):Play()
end
end
Please tell me how can i fix that.