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 9 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?

01local SCREENGUI = script.ScreenGui
02local FRAME = SCREENGUI.Frame
03 
04function onButton2Down(mouse)
05    local targ = mouse.Target
06    FRAME.Visible = true
07    --mouse.Button2Down:connect(function()
08    --  onButton2Down(mouse)
09    --end)
10end
11 
12mouse.Button2Down:connect(onButton2Down)
1
mouse is undefined. rexbit 707 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Use the :GetMouse method to get the mouse, as the mouse is undefined in this script.

1local sGui=script.ScreenGui
2local frame=sGui.Frame
3local player=game.Players.LocalPlayer
4local mouse=player:GetMouse()
5 
6local function onRightClick()
7    local targ=mouse.Target
8    frame.Visible=true
9end
0
It doesn't need a connection line? Gwolflover 80 — 9y
0
I don't think so. SimplyRekt 413 — 9y
Ad

Answer this question