Hey there, So I am working on a small project for myself - It isn’t going public, it’s staying just me. I am attempting to make a throttle system, where if it reaches 25% on the throttle, E1 starts, 50% e2, so forth to 100%. There is one I have seen, although I cannot replicate a similar method to this. As you can see here, This is what I am trying to make.
I have managed to make something similar but, When I move the slider, the audios play although it’s goes from 0 => 0.1 => 0.2 => 0 on TimePosition ( Even without moving). Is there anything I can sort of do to make the audio play correctly? (I know about the audio issue ongoing aswell.)
Here’s my script.
local holder = script.Parent.Holder
local slide =holder.Bar
local slider = holder.Bar.Slide
local N1 = script.Parent.N1
local percentage = script.Parent.Percentage
local mouse = game.Players.LocalPlayer:GetMouse()
local air
local snap = .5
local pixelsfromedge = 1.25
local moving = false
local sounds = game.ReplicatedStorage.Sounds
slider.MouseButton1Down:Connect(function()
moving = true
end)
slider.MouseButton1Up:Connect(function()
moving = false
end)
mouse.Button1Up:Connect(function()
moving = false
end)
local rpms = nil
mouse.Move:Connect(function()
if moving then
local xOffset = math.floor((mouse.X - slide.AbsolutePosition.X) / snap + .5) * snap
local xOffsetClamped = math.clamp(xOffset, pixelsfromedge, slide.AbsoluteSize.X - pixelsfromedge)
local newposslid = UDim2.new(0, xOffsetClamped, slider.Position.Y)
slider.Position = newposslid
local roundabssize = math.floor(slide.AbsoluteSize.X / snap + .5) * snap
local clamped = math.floor(xOffsetClamped / snap + .5) * snap
local slidbal = clamped / roundabssize
local rpm = slidbal * 100
wait()
local number = math.floor(rpm)
percentage.Text = rpm
--print(number)
rpms = number
end
end)
while true do
wait()
if type(tonumber(rpms)) == "number" then
if tonumber(rpms) > 0 then
local c = sounds.GE90_rpm1:Clone()
c:Play()
c.TimePosition = 0
--sounds.GE90_rpm1_Turbine:Play()
wait(1 or sounds.GE90_rpm1.TimeLength)
else
sounds.GE90_rpm1:Stop()
--sounds.GE90_rpm1_Turbine:Stop()
end
if tonumber(rpms) >= 25 then
local c = sounds.GE90_rpm2:Clone()
c.TimePosition = 0
c:Play()
wait(1 or sounds.GE90_rpm2.TimeLength)
-- sounds.GE90_rpm2_Turbine:Play()
else
-- sounds.GE90_rpm2_Turbine:Stop()
sounds.GE90_rpm2:Stop()
end
if tonumber(rpms) >= 50 then
local c = sounds.GE90_rpm3:Clone()
c.TimePosition = 0
c:Play()
wait(1 or sounds.GE90_rpm3.TimeLength)
else
sounds.GE90_rpm3:Stop()
--sounds.GE90_rpm3_Turbine:Stop()
end
if tonumber(rpms) >= 75 then
local c = sounds.GE90_rpm4:Clone()
c.TimePosition = 0
c:Play()
wait(1 or sounds.GE90_rpm4.TimeLength)
--sounds.GE90_rpm4_Turbine:Play()
else
sounds.GE90_rpm4:Stop()
--sounds.GE90_rpm4_Turbine:Stop()
end
end
end
If you can help, that’d be amazing!