So I am trying to make a GUI script where on join you get a GUI, in order to Click the Button to let the GUI disappear you need to have permission. But I think I am doing something wrong in my script.(LocalScript) Can anyone take a look into my script and see what is wrong?
gui = script.Parent Button = gui.TextButton BigText = gui.BigText Note = gui.Note NoAcces = gui.NoAccess gui.Visible = true gui.NoAccess.Visible = false Access = {["maup12345"] = true,["TristyOfficial"] = true} function OnClicked() if Access["maup12345"] == true and Access["TristyOfficial"] == true then gui.Visible = false elseif Access["maup12345"] == false and Access["TristyOfficial"] == false then gui.Visible = true gui.NoAccess.Visible = true wait(3) gui.NoAccess.Visible = false end end script.Parent.TextButton.MouseButton1Click:Connect(OnClicked)
gui = script.Parent Button = gui.TextButton BigText = gui.BigText Note = gui.Note NoAcces = gui.NoAccess gui.Visible = true gui.NoAccess.Visible = false Access = {["maup12345"] = true,["TristyOfficial"] = true} function OnClicked() if Access[game.Players.LocalPlayer.Name] ~= nil then gui.Visible = false else gui.Visible = true gui.NoAccess.Visible = true wait(3) gui.NoAccess.Visible = false end end script.Parent.TextButton.MouseButton1Click:Connect(OnClicked)
This should work, I believe the reason it wasn't working before was because in your if statement you were checking if ['maup12345'] and ['TristyOfficial'] were true, (which obviously they would be because you just set them as true in the table) which would cause the gui to always not show.
Thank you!
Just one more thing, I tried figuring out how to kick the local player who does not have access to the game but couldnt figure it out. How do I kick the local player who pressed the Button if he does not have access?