Okay, the code seems to be just fine. Is there any errors that you receive from the output?
nope its all clear for some reason
Ok, letās do some debugging.
Add print(āButton is pressedā)
after your first line of code. Test run it, and see if the output did print.
Basically pressing the button while testing, it should print.
added it, and it only prints on computer
In that case, we would need to use UserInputService. Have you ever used UserInputService?
Actually you know what, just add TouchTap:Connect(function() to the same function.
Below is alternative option.
Hereās the link to UserInputService,
Basically, you can combined multiple keybinds such as desktop key and mobile touch (tap) and Xbox controller sync to the same button.
i havent ever used userinputservice but its strange cuz before the guis always work with mousebutton1click
MouseButton1Click will always work for Desktop devices. But it will not work for Mobile because they both have different keybindings.
But wait, thereās a better way. You would need to change the coding around a bit.
Instead of script.Parent.MouseButton1Click
wrap it as a function and use MouseButton1Click(function)
as well as TouchTap:Connect(function) to sync into one function.
If that make sense.
it doesent work touchtap doesent work on any device
If you are using mouseclick I donāt think it will work I havenāt tried it
My apologies for late response, but here it is.
local Button = script.Parent
local MainFrame = Button.Parent
function UpdateUI()
if MainFrame.HatsFrame.Visible == false then
MainFrame.HatsFrame.Visible = true
MainFrame.COLOR.Visible = true
Button.Text = "Hats - On"
else
MainFrame.HatsFrame.Visible = false
MainFrame.COLOR.Visible = false
Button.Text = "Hats - Off"
end
end
Button.MouseButton1Click:Connect(UpdateUI)
Button.TouchTap:Connect(UpdateUI)
Use MouseButton1Down
instead
script.Parent.MouseButton1Down:Connect(function()
if script.Parent.Parent.HatsFrame.Visible == false then
script.Parent.Parent.HatsFrame.Visible = true
script.Parent.Parent.COLOR.Visible = true
script.Parent.Text = "Hats - On"
else
script.Parent.Parent.HatsFrame.Visible = false
script.Parent.Parent.COLOR.Visible = false
script.Parent.Text = "Hats - Off"
end
end)