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

How do I change a Player's GUI depending on a property?

Asked by 4 years ago

I'm currently working on a GUI that shows the player what song is currently playing. I have gotten a Sound object with a script that keeps changing the song, and it works just fine. And I've also done a GUI in StarterGui that shows everything.

I have a Gui, Frame and TextLabel, inside the TextLabel is a script, that should change the player's GUI based on that property, this is how it looks like:

--\\ VARIABLES

local sound = game.Workspace.Misc.PlaySongs
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local text = playerGui.CurrentSong.Frame.SongName

--// VARIABLES

--\\ CHANGER

if sound.SoundId == 3734646965 then
    text.Text = "Buttercup"
elseif sound.SoundId == 1560173003 then
    text.Text = "Oh Klahoma"
elseif sound.SoundId == 3524204087 then
    text.Text = "Dead Weight"
elseif sound.SoundId == 4664971308 then
    text.Text = "Life Could Be A Dream!"
elseif sound.SoundId == 3687583783 then
    text.Text = "Lolipop"
elseif sound.SoundId == 4509807932 then
    text.Text = "Chill Mix idrk lol"
end

But it doesn't change anything, I've tested it with a print("") as well, for some reason it does not see when the property is changed. Any help would be greatly appreciated! Thanks!

0
I am having the same exact issue as you as well, except when reading the value of a StringValue User#35964 0 — 4y
0
I have the answer,i am typing it yuni_Boy1234 320 — 4y

1 answer

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

REMEMBER: the songs not only are composed with the id! they have an extension also "rbxassetid" look:

--\\ VARIABLES

    local sound = game.Workspace.Misc.PlaySongs
    local text = script.Parent

    --// VARIABLES

    --\\ CHANGER
     while true do
         wait(0.1)
    if sound.SoundId == "rbxassetid://3734646965" then --Convert the number value to string --value
        text.Text = "Buttercup"
    elseif sound.SoundId == "rbxassetid://1560173003" then      
           text.Text = "Oh Klahoma"
    elseif sound.SoundId == "rbxassetid://3524204087" then
        text.Text = "Dead Weight"
    elseif sound.SoundId == "rbxassetid://4664971308" then
        text.Text = "Life Could Be A Dream!"
    elseif sound.SoundId == "rbxassetid://3687583783" then
        text.Text = "Lolipop"
    elseif sound.SoundId == "rbxassetid://4509807932" then
        text.Text = "Chill Mix idrk lol"
    end
end

I also highly recommend to shorten the song list part,you will need it

And change the script to server script, not local

0
I've done this and it still doesn't change my text, thank you for reminding me of the rbxassetid:// thing, but even when it is put like that the GUI doesn't change it's text, could it be a problem in the playerGui where it doesn't identify it? OrdinaryTeaCup 0 — 4y
0
I've also recorded and posted that the script has no errors or anything and the music playing and all that, here's the link, maybe it help with finding the problem? https://streamable.com/4finm7 OrdinaryTeaCup 0 — 4y
0
Try to change the local script to a server script yuni_Boy1234 320 — 4y
Ad

Answer this question