Ok, So I am trying to script a slider that when it changes it will change the Pitch of this sound to the sliders position. (divided by some number)
This doesn't seem to work, Am I doing anything wrong?
Son = script.Parent.CanvasPosition.y/255 Damn = script.Parent.Parent.Parent.Parent.Parent.SongBoard.MainWall.SurfaceGui.ScrollingFrame.Sound.Pitch script.Parent.Changed:connect(function(Val) Damn = Son --Where'd ya find this? end)
Eek, I don't know if this is possible.
Your problem is that you're setting a variable to a property. This should (pretty much) never be done. The reason is because when you set a variable to a property, that variable does not become the property. It becomes what the property equals. You can not do
local trans = part.Transparency trans = 1
because trans
does not equal the part's transparency property. It equals the number that the property was equal to at the time the variable was created.
Therefore, you must do this;
local canvasPosition = script.Parent.CanvasPosition.y/255 local sound = script.Parent.Parent.Parent.Parent.Parent.SongBoard.MainWall.SurfaceGui.ScrollingFrame.Sound script.Parent.Changed:connect(function() sound.Pitch = canvasPosition.Y / 255 end)
On a side note, you should always name variables something associated with what they are equaling, or their purpose. This increases readability (which is arguably even more important than functionality).