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

I can't Use mouse as an argument?

Asked by 8 years ago

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)

1
mouse is undefined. rexbit 707 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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
0
It doesn't need a connection line? Gwolflover 80 — 8y
0
I don't think so. SimplyRekt 413 — 8y
Ad

Answer this question