• Добро пожаловать! Если у вас не проходит регистрация - попробуйте отключить программы, которые могут изменять интернет-подключение.

[SOLVED] Текст меняется, при этом не меняется

Статус
В этой теме нельзя размещать новые ответы.

hpasus8

Пользователь
Регистрация
Фев 15, 2025
Сообщения
11

ПРОБЛЕМА РЕШЕНА​

Всех приветствую!

В моей игре есть скрипт, который меняет название текста в textButton.
Как видите, в картинке ниже Text в Properties поменялся, а в игре как остался Now playing:, так и остаётся Now playing:.
1739632966133.png


Скрипт:
LUA:
local SoundService = game:GetService("SoundService")
local currentMusic = SoundService:FindFirstChild("BackgroundMusic")
local nowPlays = script.Parent:WaitForChild('nowPlaysText') -- тот самый textButton

local function updateNowPlaying()
    local currentMusic = SoundService:FindFirstChildOfClass("Sound")
    if currentMusic and currentMusic.IsPlaying then
        nowPlays.Text = "Now Playing: " .. currentMusic.Name
    end
end

SoundService.ChildAdded:Connect(updateNowPlaying)
SoundService.ChildRemoved:Connect(updateNowPlaying)
updateNowPlaying()

Заранее спасибо за помощь!
 
Последнее редактирование:
Решение
мб так:


LUA:
local SoundService = game:GetService("SoundService")
local nowPlays = script.Parent:WaitForChild('nowPlaysText')

local function updateNowPlaying()
    local currentMusic = SoundService:FindFirstChildOfClass("Sound")
    if currentMusic and currentMusic.IsPlaying then
        nowPlays.Text = "Now Playing: " .. currentMusic.Name
    else
        nowPlays.Text = "No music playing"
    end
end

SoundService.ChildAdded:Connect(function(child)
    if child:IsA("Sound") then
        child.Ended:Connect(updateNowPlaying)
        child.Stopped:Connect(updateNowPlaying)
        updateNowPlaying()
    end
end)

SoundService.ChildRemoved:Connect(updateNowPlaying)

updateNowPlaying()
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху