|
| 20 Mar 2017 02:03 PM |
I've come seeking some help. First and foremost I AM NOT a very good scripter, for two years I have been able to script anything I needed to get done with my small knowledge of the skill. and today I have hit that limit.
I would like to ask the question, is there a way to play then toggle the pitch of a sound/audio via a drag-able screen GUI? The goal would be a GUI that activates when a player sits in a seat, and is removed when the play gets up. (I know how to do this much, but the rest is totally out of my zone.) Something like a GUI that is confined to one area and you can drag down to turn on the sound and said sounds' pitch changes as you pull it down. then the pitch returns to normal as you pull the GUI back up and when you let go it turns off.
(this whole concept is for a Steam Locomotive Whistle rope that I have wanted to make for a long time as a GUI for a community of train builders here on Roblox.)
I know its a tall order but does anyone know how to do at least the drag-able GUI part that can change the pitch depending on how far down the GUI is pulled and turn the sound on/off when the GUI is clicked and let go? (PS. Thank you for reading this!) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 20 Mar 2017 02:16 PM |
scroll.Changed:connect(function() sound.Pitch = 1-scroll.AbsolutePosition.Y/(bar.AbsolutePosition.Y+bar.AbsoluteSize.Y) end)
something like that. that would be the scale
|
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 02:33 PM |
it has to stay in the same X position, only the Y can really be able to move up and down, also how would I write the script to make the sound play when the gui is clicked and held..? (I'm not very experienced, but every new workaround I learn quickly and can apply it later on!) |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 02:35 PM |
| The script already makes it stay in the x position. |
|
|
| Report Abuse |
|
|
Atavis
|
  |
| Joined: 10 Apr 2012 |
| Total Posts: 1463 |
|
|
| 20 Mar 2017 02:39 PM |
http://wiki.roblox.com/index.php?title=Sounds http://wiki.roblox.com/index.php?title=The_Fundamentals_of_Scripting_with_GUIs http://wiki.roblox.com/index.php?title=Intro_to_GUIs
http://wiki.roblox.com/index.php?title=API:Class/Sound http://wiki.roblox.com/index.php?title=API:Class/TextLabel http://wiki.roblox.com/index.php?title=API:Class/TextButton
121,433 slices of pizza and counting! |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 02:44 PM |
| now how would I make a way for it to turn on/off when clicked and this would be a screen GUI because its in a seat correct? |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 03:08 PM |
I am becoming extremely confused now, can someone write out the script in the form of a Dragable Gui in a vechile seat? I cannot use scroll.Changed:connect(function() sound.Pitch = 1-scroll.AbsolutePosition.Y/(bar.AbsolutePosition.Y+bar.AbsoluteSize.Y) end) because I have no idea how to set this up (in a seat at least) |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 03:22 PM |
| do you have any more advice on how to do this? I can even get a GUI to appear when I sit in a seat, much less write the script from scratch without knowing what frames /text buttons there are inside. |
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 03:37 PM |
| you know that does not help at all, you just linked me to the wiki which I have read before =_= |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 20 Mar 2017 04:22 PM |
it would be something like this.
local scale = (frame.AbsolutePosition.Y+frame.AbsoluteSize.Y)/main.AbsolutePosition.Y
sound.Pitch = scale
just depends on how you want it
|
|
|
| Report Abuse |
|
|
|
| 20 Mar 2017 04:34 PM |
| I don't even... just theres no sound = whatever the path to the sound is.. could you try writing out a whole script to explain what your method is? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 20 Mar 2017 04:39 PM |
...
--local sript
wait() local player = game.Players.LocalPlayer local mouse = player:GetMouse() local main = script.Parent local frame = main.Parent local sound = main:WaitForChild('Sound') sound:Play()
main.Changed:connect(function() main.Position = UDim2.new(0,0,0,mouse.Y-frame.AbsoluteSize.Y) local scale = (frame.AbsolutePosition.Y+frame.AbsoluteSize.Y)/main.AbsolutePosition.Y sound.Pitch = scale end)
|
|
|
| Report Abuse |
|
|
|
| 27 Mar 2017 06:32 PM |
| How would I constrain the pitch (the sound stops if it push the button above the frame (good! I have a way to turn it off) but as I come back down the pitch is way to high and it is very annoying/ ear splitting, is there a way to make a maximum/minimum pitch for the sound?) |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 27 Mar 2017 07:24 PM |
https://www.roblox.com/games/537051884/Sound
(Sorry, I couldn't find a sound that looped properly on short notice)
|
|
|
| Report Abuse |
|
|
|
| 27 Mar 2017 08:54 PM |
| Thank you for that! I have made a work around for all this but that seems to do the trick, to all of you who send segestions and provided insight Thank You! |
|
|
| Report Abuse |
|
|
|
| 27 Mar 2017 10:01 PM |
| one final question though, if you have time could you create a bit more script under local script? id like the whistle to be able to "Quill" down (after mouse button up instead of the sound stopping instantly the pitch returns to normal starting pitch and the volume goes down so it isn't such a quick on/off transition, id like the sound to taper off before shutting off) if it isn't too much to ask, could you do this? (thank you in advance even for just thinking about it XD) |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
|
| 28 Mar 2017 03:09 PM |
| that seems to be good, I'm going to try by myself to condense all the functions and hopefully remove the need to use server script storage and starter GUI from the equation, its less complex if its all condensed into a vehicle seat and doesn't need the starter GUI and or the server storage (that way a model with the script can be inserted into any game without needing the owner to put the GUI in the starter GUI and the sound remote event in the storage) also, would you be willing to teach me a little about scripting? (I'm a fast learner, and know a little already but would love to learn more! :D) |
|
|
| Report Abuse |
|
|