So I'm trying to make a script where you click on any brick in the game and a GUI box pops up. I successfully made an importer script that puts this script in PlayerScripts for every player that joins the game, but now I'm having trouble actually making this script work. Again, the goal of this script is when a player right-clicks on any brick in the game a GUI box pops up on their screen. Am I not supposed to use mouse as an argument for onButton2Down()? I tried (part) as well but that didn't work either. The script seems like it would work except in the connection line at the bottom it isn't recognizing mouse. How can I fix this?
local SCREENGUI = script.ScreenGui local FRAME = SCREENGUI.Frame function onButton2Down(mouse) local targ = mouse.Target FRAME.Visible = true --mouse.Button2Down:connect(function() -- onButton2Down(mouse) --end) end mouse.Button2Down:connect(onButton2Down)
Use the :GetMouse
method to get the mouse, as the mouse is undefined in this script.
local sGui=script.ScreenGui local frame=sGui.Frame local player=game.Players.LocalPlayer local mouse=player:GetMouse() local function onRightClick() local targ=mouse.Target frame.Visible=true end