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 5 years ago
local a=1
while a<10 do
    game.SoundService.allstar.PlaybackSpeed=a
    a=game.SoundService.allstar.PlaybackSpeed+1
    wait(1)
end

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 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 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?:

local a=1
while a<10 do
    game.SoundService.allstar.PlaybackSpeed=a
    a=game.SoundService.allstar.PlaybackSpeed+1
    wait(1)
end


to

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


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
5 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.
local SoundService = game:GetService("SoundService") -- Sound Service
local Sound = SoundService:WaitForChild("allstar") -- The Sound Object

local Pitch = 1 -- PlaybackSpeed
Sound:Play()
while Pitch<10 do
Sound.PlaybackSpeed = Pitch -- Changes PlaybackSpeed
Pitch = Pitch + 1 -- adds 1 to pitch
wait(1) -- waits
end
0
i did! CommanderCaubunsia 126 — 5y

Answer this question