I'm creating a button on the player screen so that it can change the music on the map, so I created a script that does it and added a feature so that the image always changes from a microphone to a microphone with an X in the middle (representing that the music is mutated). The problem from what I realized is that when he dies, the image returns to the default. This can disturb the player because if he changes music and dies, the music will play again and the image will not represent what is happening.
local player = game.Players.LocalPlayer
local db = false
function Test ()
if db == false then
db = true
if player.Character.Head:FindFirstChild('Music') ~= nil then
player.Character.Head.Music:Pause()
script.Parent.Image = 'rbxassetid://2293422655'
end
elseif db == true then
db = false
if player.Character.Head:FindFirstChild('Music') ~= nil then
player.Character.Head.Music:Resume()
script.Parent.Image = 'rbxassetid://1351370316'
end
end
end
script.Parent.MouseButton1Down:Connect(test)
player.Character.Humanoid.Changed:Connect(function()
if player.Character.Humanoid.Health == 0 then
script.Parent.Visible = false
end
end)
MY QUESTION IS: HOW DO I MAKE THE IMAGE THAT WAS ON IMAGEBUTTON BEFORE THE PLAYER DIED, REMAIN THE SAME AFTER HE DIED?

1 comment
https://developer.roblox.com/en-us/api-reference/property/LayerCollector/ResetOnSpawn