Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm trying to make a frame visible my right clicking.?

Asked by 4 years ago
Edited 4 years ago

This local script is in StarterPlayerScripts:

local mouse = game.Player.LocalPlayer:GetMouse()
    mouse.Button1down:Connect(function()
    StarterGui.ScreenGui.Frame.Visible = true
    end)
    end)

The frame is in screen gui that is the child of starter gui

2 answers

Log in to vote
1
Answered by 4 years ago

this is easy to do as not only you can use it for this, but you can use it for click detectors and so on.

i am assuming you are using a text button to do this, or anything relevant to that.

you would instead put the local script into the button that is parented to the screen GUI.

(at least, this is how i do it and have done it)

but anyways, in order for the script to detect a RIGHT CLICK, you would use 'MouseButton2Click', like below:



script.Parent.MouseButton2Click:Connect(function() --this starts the function for the script if script.Parent.Frame.Visible == false then --this detects if it is not visible script.Parent.Frame.Visible = true --this makes it true so it then is visible else script.Parent.Frame.Visible = false --you can keep 'else' and this line here if you also want to turn it off end end)

hopes this helps!!

0
script.Parent.Frame.Visible = not script.Parent.Frame.Visible Roger111 347 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

When you have a gui, and you run the game, the gui you want to edit is in playergui lol.

Unless this script is a localscript, you have to make the scripts parent the gui itself, and change up the code.

If it IS a localscript, then do the following.

local plr = game.Players.LocalPlayer
local plrGui = plr.PlayerGui
local mouse = plr:GetMouse()

mouse.Button1Down(function())
    plrGui.YourGuiNameHere.Frame.Visible = false
end)

(People might not like this answer due to it editing the playerGui, but it works for me lol.)

Answer this question