I am trying to fix a bug where when I press a button it does 2 events [1 it is not supposed to do]
Clip:
Click here for the clip.
Code
local GROUP_ID = 11587846
local player = game:GetService("Players").LocalPlayer
local rank = player:GetRoleInGroup(GROUP_ID)
local rankid = player:GetRankInGroup(GROUP_ID)
local playerGui = player.PlayerGui
local gui = playerGui:WaitForChild("settings")
local settings1 = gui.settings
local credits = playerGui:WaitForChild("credits").credits
local Icon = require(game:GetService("ReplicatedStorage").Icon)
local musicsong = workspace.currentsong
if rankid == 0 then
rank = "âś…| Visitor"
end
Icon.new()
:setName("rank")
:setRight()
:lock()
:setSize(100, 32)
:setImage(7199868835)
:setLabel(rank, "deselected")
:setLabel(rank, "selected")
:setLabel("RankID: " .. rankid, "hovering")
Icon.new()
:setName("Settings")
:setImage(7202333684)
:setCaption("Settings(g)")
:bindToggleKey(Enum.KeyCode.G)
:bindEvent("selected", function()
settings1.Visible = true
end)
:bindEvent("deselected", function()
settings1.Visible = false
end)
Icon.new()
:setName("Credits")
:setImage(7199802249)
:notify()
:setRight()
:setCaption("Credits(c)")
:bindToggleKey(Enum.KeyCode.C)
:bindEvent("selected", function()
credits.Visible = true
end)
:bindEvent("deselected", function()
credits.Visible = false
end)
Icon.new()
:setName("Current-Song")
:setImage(7203694787)
:setMid()
:setSize(100,32)
:setDropdown({
Icon.new("MuteMusic")
:setLabel("Mute Music")
:bindToggleKey(Enum.KeyCode.M)
:bindEvent("selected", function(CurrentSong)
game.Workspace.music.Song1.Volume = 0
game.Workspace.music.Song3.Volume = 0
game.Workspace.music.Song2.Volume = 0
game.Players.LocalPlayer.muted.Value = true
if game.Players.LocalPlayer.muted.Value == true then
print("Muted....")
repeat
wait(0.1)
game.Workspace.currentsong.Value = "Muted!"
until game.Players.LocalPlayer.muted.Value == false
end
end)
:bindEvent("deselected", function(currentsongde)
game.Workspace.music.Song1.Volume = 0.8
game.Workspace.music.Song3.Volume = 0.8
game.Workspace.music.Song2.Volume = 0.8
game.Workspace.currentsong.Value = "Unmuted (Give a moment to update)"
wait(3)
if game.Workspace.music.Song1.Playing == true then
game.Workspace.currentsong.Value = "Kuzu Mellow - sunflower feelings (prod. by korou)"
end
if game.Workspace.music.Song2.Playing == true then
game.Workspace.currentsong.Value = "timmies - loosing interest (ft. shiloh)"
end
if game.Workspace.music.Song3.Playing == true then
game.Workspace.currentsong.Value = "Sarcastic Sounds - 'I Don't Sleep'"
end
repeat
wait(0.1)
game.Players.LocalPlayer.muted.Value = false
until game.Players.LocalPlayer.muted.Value == true
end)
})
:give(function(icon)
musicsong.Changed:Connect(function(value)
icon:setLabel(value)
end)
end)
Current Key bindings:
C - Credits
G - Settings
M - Mute/Unmute Music (Having the issue with)
Script originally by @ForeverHD
For some reason C AND G are triggering M.
Abcreator
(Abcreator)
August 6, 2021, 2:12am
#2
What’s the thing you don’t want to happen?
1 Like
NotAxIr
(axlr)
August 6, 2021, 2:13am
#3
Could you elaborate on which button isn’t working, can’t exactly see what is fully going on in the video?
1 Like
To, @NotAxIr and @Abcreator This has been updated, Thank you for your feedback.
Abcreator
(Abcreator)
August 6, 2021, 2:47am
#5
Does G trigger C by any chance?
READ IT…
I hate repeating myself…
Abcreator
(Abcreator)
August 6, 2021, 3:04am
#7
The only thing I could think of is possibly chained events could be messing up, try this:
local GROUP_ID = 11587846
local player = game:GetService("Players").LocalPlayer
local rank = player:GetRoleInGroup(GROUP_ID)
local rankid = player:GetRankInGroup(GROUP_ID)
local playerGui = player.PlayerGui
local gui = playerGui:WaitForChild("settings")
local settings1 = gui.settings
local credits = playerGui:WaitForChild("credits").credits
local Icon = require(game:GetService("ReplicatedStorage").Icon)
local musicsong = workspace.currentsong
if rankid == 0 then
rank = "âś…| Visitor"
end
local Rank = Icon.new()
Rank:setName("rank")
Rank:setRight()
Rank:lock()
Rank:setSize(100, 32)
Rank:setImage(7199868835)
Rank:setLabel(rank, "deselected")
Rank:setLabel(rank, "selected")
Rank:setLabel("RankID: " .. rankid, "hovering")
local Settings = Icon.new()
Settings:setName("Settings")
Settings:setImage(7202333684)
Settings:setCaption("Settings(g)")
Settings:bindToggleKey(Enum.KeyCode.G)
Settings:bindEvent("selected", function()
settings1.Visible = true
end)
Settings:bindEvent("deselected", function()
settings1.Visible = false
end)
local Credits = Icon.new()
Credits:setName("Credits")
Credits:setImage(7199802249)
Credits:notify()
Credits:setRight()
Credits:setCaption("Credits(c)")
Credits:bindToggleKey(Enum.KeyCode.C)
Credits:bindEvent("selected", function()
credits.Visible = true
end)
Credits:bindEvent("deselected", function()
credits.Visible = false
end)
local Dropdown = Icon.new()
Dropdown:setName("Current-Song")
Dropdown:setImage(7203694787)
Dropdown:setMid()
Dropdown:setSize(100,32)
Dropdown:setDropdown({
local Music = Icon.new("MuteMusic")
Music:setLabel("Mute Music")
Music:bindToggleKey(Enum.KeyCode.M)
Music:bindEvent("selected", function(CurrentSong)
game.Workspace.music.Song1.Volume = 0
game.Workspace.music.Song3.Volume = 0
game.Workspace.music.Song2.Volume = 0
game.Players.LocalPlayer.muted.Value = true
if game.Players.LocalPlayer.muted.Value == true then
print("Muted....")
repeat
wait(0.1)
game.Workspace.currentsong.Value = "Muted!"
until game.Players.LocalPlayer.muted.Value == false
end
end)
Music:bindEvent("deselected", function(currentsongde)
game.Workspace.music.Song1.Volume = 0.8
game.Workspace.music.Song3.Volume = 0.8
game.Workspace.music.Song2.Volume = 0.8
game.Workspace.currentsong.Value = "Unmuted (Give a moment to update)"
wait(3)
if game.Workspace.music.Song1.Playing == true then
game.Workspace.currentsong.Value = "Kuzu Mellow - sunflower feelings (prod. by korou)"
end
if game.Workspace.music.Song2.Playing == true then
game.Workspace.currentsong.Value = "timmies - loosing interest (ft. shiloh)"
end
if game.Workspace.music.Song3.Playing == true then
game.Workspace.currentsong.Value = "Sarcastic Sounds - 'I Don't Sleep'"
end
repeat
wait(0.1)
game.Players.LocalPlayer.muted.Value = false
until game.Players.LocalPlayer.muted.Value == true
end)
})
Dropdown:give(function(icon)
musicsong.Changed:Connect(function(value)
icon:setLabel(value)
end)
end)
This will not work… Looks like a useless edit… Any other useful idears people?
The reason your events are triggering is because pressing “G” or “C” (or even clicking on the GUI buttons those keys are bound to) causes those elements to become “selected” in the framework’s code, forcibly deselecting the mute control, which, in turn, fires the mute control’s bound deselect logic. You need to call this on your mute icon:
:setProperty("deselectWhenOtherIconSelected",false)
Also, I saw your other post regarding this framework in the process of learning about it. Have you considered trying to be more gracious when asking for help?