Property value changes, but when referencing in code doesn't update

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
Screenshot 2024-11-18 185045
Yes, Position.Y.Offset is 10

Now this is what happens when I move the slider
Screenshot 2024-11-18 185059
Screenshot 2024-11-18 185151

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

Is it a LocalScript? If not then the script won’t recognize changes in the position of the slider. In that case you’d need to use a RemoteEvent

1 Like

It’s a normal not a local script.

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)
1 Like

It still doesn’t seem to work but it’s definitely a step in the right direction

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

1 Like



Screenshot 2024-11-19 165909
Screenshot 2024-11-19 165917

Thank you! And no errors?

In the OnServerEvent event could you add print(playbackSpeed)?

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)

1 Like

Done, but it seems like it’s spitting out an error that makes the whole thing pretty much not run I think



It is the correct path, I don’t know why it says that

When testing the game check the workspace on both the Server and Client and let me know if you see the Model there

If by model you mean the whole thing they appear on both, also the slider appears
Or maybe you’re referring to something else?

Yeah that’s what I meant. Okay, in the client script change it to

local mixObj = game.Workspace:WaitForChild("Sophienatorz Mix")

Sorry I should’ve written it that way to start with; sometimes the map takes a while to load in on the client

Hmmmmm it still doesn’t work for some reason

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)

What do you get in the output?


Only output I see

Ahh yes, I forgot to change that path when we moved the script—my bad. It should be:

local dragger: UIDragDetector = handle:WaitForChild("UIDragDetector")

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:

1 Like