I’m trying to make a simple slider with the new UiDragDetectors, that’s unrelated to this however.
Let me show you; I have this script
while task.wait(0.01) do
game.Workspace["Sophienatorz Mix"].Mixer.MusicPlayer.ImageButton.Script.Song.PlaybackSpeed = (script.Parent.Position.Y.Offset - 95) / (0 - 95)
end
All paths are completely correct and the loop is looping, adding a print statement to this:
I run the code
Yes, Position.Y.Offset is 10
Now this is what happens when I move the slider
Clearly it is not still 10 as you can see, it just won’t update. This has been frustrating me for about a day and I tried everything
Okay, since it’s a ServerScript that’s what’s causing the problem. Let’s use RemoteEvents!
Okay I constructed two small scripts. Unfortunately I’m not able to test them right now but let me know if they work. Replace the ServerScript in the UI with a LocalScript then insert a new ServerScript inside ServerScriptService.
LocalScript
--[[ so first before using this script, insert a folder into ReplicatedStorages called "remotes"
or something else. Then, in that foler add a RemoteEvent called "playbackRemote" or something.
In these following lines I'll reference them:
]]
local remotes: Folder = game:GetService("ReplicatedStorage").remotes
local playbackRemote: RemoteEvent = remotes.playbackRemote
local handle = script.Parent
local dragger: UIDragDetector = script.Parent:WaitForChild("dragger") --[[ whatever the name of the
UIDragDetector is
]]
dragger.DragContinue:Connect(function()
local speed = (handle.Position.Y.Offset - 95) / (0 - 95)
--you could also make the system scale instead of offset in conjunction with changing the
-- UIDragDector's ResponseStyle to Scale
playbackRemote:FireServer(speed)
end)
ServerScript
-- Now the following Code would go in a ServerScript in ServerScriptService
local remotes: Folder = game:GetService("ReplicatedStorage").remotes
local playbackRemote: RemoteEvent = remotes.playbackRemote
local mixObj = game.Workspace["Sophienatorz Mix"]
local musicPlayer = mixObj.Mixer.MusicPlayer
local playbackMinSpeed, playbackMaxSpeed = 0.5, 15 -- Adjust this as you wish, in conjunction with the LocalScript
playbackRemote.OnServerEvent:Connect(function(player, playbackSpeed)
if typeof(playbackspeed) ~= "number" then return end -- Exploiters may send non-number things. You don't need this as an error would only cancel the function
musicPlayer.ImageButton.Script.Song.PlaybackSpeed = math.clamp(playbackSpeed, playbackMinSpeed, playbackMaxSpeed)
end)
Ah sorry about that. Maybe you could upload the adjusted code and a screenshot of the explorer so I can see the object hierarchy. Also do print debugging as well as mentioning any errors you get in output
Oh I just realized, the UI is a descendant of the workspace. You’ll have to move the LocalScript to StarterPlayerScripts for it to be able to run. Then change the LocalScript to:
--[[ so first before using this script, insert a folder into ReplicatedStorages called "remotes"
or something else. Then, in that foler add a RemoteEvent called "playbackRemote" or something.
In these following lines I'll reference them:
]]
local remotes: Folder = game:GetService("ReplicatedStorage").remotes
local playbackRemote: RemoteEvent = remotes.playbackRemote
local mixObj = game.Workspace["Sophienatorz Mix"]
local musicPlayer = mixObj.Mixer.MusicPlayer
local handle = mixObj.Mixer.EQ3.Low.Slider
local dragger: UIDragDetector = script.Parent:WaitForChild("UIDragDetector") --[[ whatever the name of the
UIDragDetector is
]]
dragger.DragContinue:Connect(function()
local speed = (handle.Position.Y.Offset - 95) / (0 - 95)
--you could also make the system scale instead of offset in conjunction with changing the
-- UIDragDector's ResponseStyle to Scale
playbackRemote:FireServer(speed)
end)
Just to be extra sure everything is loaded in I made a few adjustments, but I think you’ll need to use prints to see what’s not working. Try this
Local Script
--[[ so first before using this script, insert a folder into ReplicatedStorages called "remotes"
or something else. Then, in that foler add a RemoteEvent called "playbackRemote" or something.
In these following lines I'll reference them:
]]
local remotes: Folder = game:GetService("ReplicatedStorage"):WaitForChild("remotes")
local playbackRemote: RemoteEvent = remotes:WaitForChild("playbackRemote")
local mixObj = game.Workspace:WaitForChild("Sophienatorz Mix")
local musicPlayer = mixObj:WaitForChild("Mixer"):WaitForChild("MusicPlayer")
local handle = mixObj:WaitForChild("Mixer"):WaitForChild("EQ3"):WaitForChild("Low"):WaitForChild("Slider")
local dragger: UIDragDetector = script.Parent:WaitForChild("UIDragDetector") --[[ whatever the name of the
UIDragDetector is
]]
dragger.DragContinue:Connect(function()
print("1 dragging")
local speed = (handle.Position.Y.Offset - 95) / (0 - 95)
print("2 speed:"..speed)
--you could also make the system scale instead of offset in conjunction with changing the
-- UIDragDector's ResponseStyle to Scale
playbackRemote:FireServer(speed)
print("3 server fired")
end)
ServerScript
-- Now the following Code would go in a ServerScript in ServerScriptService
local remotes: Folder = game:GetService("ReplicatedStorage").remotes
local playbackRemote: RemoteEvent = remotes.playbackRemote
local mixObj = game.Workspace["Sophienatorz Mix"]
local musicPlayer = mixObj.Mixer.MusicPlayer
local playbackMinSpeed, playbackMaxSpeed = 0.5, 15 -- Adjust this as you wish, in conjunction with the LocalScript
playbackRemote.OnServerEvent:Connect(function(player, playbackSpeed)
print("4 server event")
--if typeof(playbackSpeed) ~= "number" then return end -- Exploiters may send non-number things. You don't need this as an error would only cancel the function
print("5 playback speed:".. playbackSpeed)
musicPlayer.ImageButton.Script.Song.PlaybackSpeed = math.clamp(playbackSpeed, playbackMinSpeed, playbackMaxSpeed)
end)
Oh my god.
Thank you so much actually you have no idea how much this helped me I was so confused for the last 2 days thank you so so so so much now it works, and I’ve learned how to use some stuff in the way
Glad to hear it helped! I apologize about it taking so many iterations—I made some silly mistakes that held it up from working haha
If you run into any issues with your sliders in the future I’ll try my best to assist. I’ve been coding a lot of systems based around UIDragDetectors so I’ve gotten a bit more comfortable with coding them
Nice! Here are some resources that may be of further help: