Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

SurfaceGui Pitch Slider Help??

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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

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 :]. NotSoNorm 777 — 9y
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. Perci1 4988 — 9y
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 NotSoNorm 777 — 9y
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. Perci1 4988 — 9y
Ad

Answer this question