What do you want to achieve? Keep it simple and clear!
Im trying to make an audio decrease volume when button is pressed in a for loop!
What is the issue? Include screenshots / videos if possible!
it isn’t decreasing when the button is pressed.
local s = workspace.SoundA
local p = game.Players.LocalPlayer
local off = false
s.Looped = true
local function playr()
s:Play()
end
playr()
p.PlayerGui.StartMenu.MainMenu.TextButton1.MouseButton1Click:Connect(function()
if off then
for i = 1, 10 do
s.Volume = s.Volume - 0.1
wait(0.1)
end
end
end)
Did not work, this is a localscript. Is that fine? I want it to be restricted to only the player so the whole game wont hear the main menu music.
local s = workspace.SoundA
local p = game.Players.LocalPlayer
local off = false
s.Looped = true
local TweenService = game:GetService("TweenService")
local function playr()
s:Play()
end
playr()
p.PlayerGui.StartMenu.MainMenu.TextButton1.MouseButton1Click:Connect(function()
TweenService:Create(s, TweenInfo.new(1, Enum.EasingStyle.Linear), {Volume = 0}):Play()
end)
Where is this script located? If it’s located in Workspace, LocalScripts don’t run there. Try parenting the LocalScript under your TextButton1 instance.
local TweenService = game:GetService("TweenService")
local Button = script.Parent
local s = workspace.SoundA
s.Looped = true
local function playr()
s:Play()
end
playr()
Button.Activated:Connect(function()
local tween = TweenService:Create(s, TweenInfo.new(1, Enum.EasingStyle.Linear), {Volume = 0})
tween:Play()
end)