Search code examples
luaroblox

How would you set visibility property of textbutton from server? [Roblox]


I'll make this really simple. I'm making an admin commands system and I'm trying to turn on a TextButton inside of the player (plr.PlayerGui.adminUi) when they chat ":cmdb". I've debbuged with print statements and all works. I added a print statement to tell me the status of "commandbar.Visibility" and it says that it's true, even though you can't see it and the checkbox in properties is false.

This is what I've had so far, with no error messages. This works the first time, but never works again. (this is in a module script)

commands.cmdb = {0, function(plr, rsp)
    game.Players[plr.Name].PlayerGui.adminUi.commandbar.Visible = true
end}

This is the explorer:
explorer image

and this is the code for "Exit":

script.Parent.MouseButton1Up:Connect(function()
    script.Parent.Parent.Visible = false
end)

Any help is appreciated, and if I missed anything neccessary, please let me know!


Solution

  • What you need to do is use remote events to connect the player to the server and you have to use a local script to change the visibility. :fireclient(player) is what you need to do from the server side

    https://developer.roblox.com/en-us/api-reference/function/RemoteEvent/FireServer