Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

SurfaceGui Pitch Slider Help??

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.

1 answer

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).

4 comments

0

I see where you are going from that, It's just the script isn't working. You got the pitch to change but it just instantly goes to 0, But thanks :].

0

I have never used a scrolling frame before. When I tried to change it to 5,5 manually, I got a warning in the output that said "ScrollingFrame.CanvasPosition set to invalid position (5.000000, 5.000000), clamping to position (0.000000, 0.000000)." Try asking a question about scrolling frames, I'm sure someone here has used them before.

0

I belive you can only change in the direction you had it set so it would be 0,5 or 5,0 not 5,5

0

Nope, it gives the same warning. My answer is still a valid thing that must be fixed, but I don't know enough about ScollingFrames to be more of a help.

This discussion is preserved as it was. New answers, comments, and votes are closed.