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

Why isn't the sound that I'm trying to make rise in pitch rising?

Asked by 6 years ago
1local a=1
2while a<10 do
3    game.SoundService.allstar.PlaybackSpeed=a
4    a=game.SoundService.allstar.PlaybackSpeed+1
5    wait(1)
6end

This is a script i'm using (allstar is the name of the sound i'm playing) and I need help making a loop like this so that the song speeds up until it's incomprehensible.

0
Thinking... CommanderCaubunsia 126 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

OH I THINK I UNDERSTAND NOW, so the a=blablabla =+ 1 can be a problem. NOt that its not in quotes. quotes are for string). but i think its that when you set variable that equals something then does something to it, its kind of like a function, so its mor like a = do this, and that is not a number so i cant be less than 10, so do this maybe?:

1local a=1
2while a<10 do
3    game.SoundService.allstar.PlaybackSpeed=a
4    a=game.SoundService.allstar.PlaybackSpeed+1
5    wait(1)
6end

to

1for a = 1,10,1-- makes sound volume go from 1 to 10 by ones.
2    game.SoundService.allstar.PlaybackSpeed = a -- preforms action on this sound
3    wait(1)--wait 1 second, 1!
4end

So basicly i litteraly changed like the whole thing to a for loop until it finishes. This makes every second the sound or whatever goes 1 higher because a means go from 1 to ten by ones so every second yeah, it does that. Hope this helps / answered this :D

OH and by the way in case you dont know, dont waste storage in workspace, make a script in ServerScriptService and put this code inside and script will work. kk dude;)

Ad
Log in to vote
0
Answered by
LuaDLL 253 Moderation Voter
6 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
01local SoundService = game:GetService("SoundService") -- Sound Service
02local Sound = SoundService:WaitForChild("allstar") -- The Sound Object
03 
04local Pitch = 1 -- PlaybackSpeed
05Sound:Play()
06while Pitch<10 do
07Sound.PlaybackSpeed = Pitch -- Changes PlaybackSpeed
08Pitch = Pitch + 1 -- adds 1 to pitch
09wait(1) -- waits
10end
0
i did! CommanderCaubunsia 126 — 6y

Answer this question