I have made a plugin for this module to make adding sliders easier for users.
It’s private
Fixed. Should be on sale for free
what wrong with my script?
i try to use Changed in my script but this give error
ReplicatedStorage.Modules.Slider.Utils.Signal:51: invalid argument #1 to 'unpack' (table expected, got nil)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Slider = require(ReplicatedStorage.Modules:WaitForChild("Slider"))
local holderFrame = script.Parent.Frame
local currentCamera = workspace.CurrentCamera
local working = true
local boombox = game.Players.LocalPlayer.Character:WaitForChild("Boombox"):WaitForChild("Object").Value
local sound = boombox:WaitForChild("Sound")
function timel()
repeat wait(0.05) until sound.IsLoaded
if sound.TimeLength == 0 then
return 0.5
else
return sound.TimeLength
end
end
local TimeSlider = Slider.new(holderFrame, {
SliderData = {Start = 0.1, End = timel(), Increment = 0.1},
MoveInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad)
})
print(TimeSlider)
sound:GetPropertyChangedSignal("SoundId"):Connect(function()
working = false
TimeSlider:Destroy()
print(TimeSlider)
TimeSlider = Slider.new(holderFrame, {
SliderData = {Start = 0.1, End = timel(), Increment = 0.1},
MoveInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad)
})
TimeSlider:Track()
working = true
end)
TimeSlider.Changed:Connect(function(newFov: number)
workspace.CurrentCamera.FieldOfView = newFov
end)
TimeSlider:Track()
while wait(0.1) do
--TimeSlider:OverrideValue(sound.TimePosition)
end
Quick FYI, I am going on a holiday for about a week or two however when I return I do plan on giving this module a backwards-compatible rewrite which should hopefully fix a lot of problems being reported
You must note that the holder must be a descendant of PlayerGUI; otherwise, the scale will be read as NaN. I discovered this after an hour of debugging because the slider disappeared. It turns out the slider must be created after the holder is cloned into PlayerGUI. @Krystaltinan
Before
local holder = x:Clone()
local slider = SliderService.new(holder)
holder.Parent = player.PlayerGUI
After
local holder = x:Clone()
holder.Parent = player.PlayerGUI
local slider = SliderService.new(holder)
If I may suggest, please consider adding new signals like onBackgroundClick
and possibly overridden
, because relying solely on changed
makes it somewhat difficult to determine what has changed and what caused it. Aside from that, this module is already excellent, although I had to make a few modifications to fit my specific needs.
Hey, does anyone have a clue how to make it so you can start dragging from the background frame?
[Solved] If anyone’s interested, I just put this line of code:
table.insert(self._data._clickConnections, self._data.HolderButton.MouseButton1Down:Connect(function()
self.IsHeld = true
end))
Here:
if self._data._allowBackgroundClick then
table.insert(self._data._clickConnections, self._data.HolderButton.MouseButton1Down:Connect(function()
self.IsHeld = true
end))
table.insert(self._data._clickConnections, self._data.HolderButton.Activated:Connect(function(inputObject: InputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 or inputObject.UserInputType == Enum.UserInputType.Touch then
if self.IsHeld then
self._data._inputPos = inputObject.Position
self._data._clickOverride = true
self:Update()
self._data._clickOverride = false
end
end
end))
end
Hope it helps someone )
Slider.Changed fires constantly while dragging, not when the value actually changes?
Fixed this by using an oldValue variable:
slider.Changed:Connect(function(newValue)
if newValue ~= oldValue then
oldValue = newValue
buttonSound:Play()
end
end)