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

(SOLVED) 'Players.InfinityNessYT.PlayerGui.Script:7: attempt to index nil with 'GetMouse''?

Asked by 3 years ago
Edited by JesseSong 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

So i am trying to make a FE glitcher script, but i don't know how to make one so i copied a little bit of the script and pasted it in, what i am trying to do is if the player clicks leftclick then it does a action and then prints what action you did, but i am trying to get the player's mouse but i keep getting the error "attempt to index nil with GetMouse". I am using a script, because it is going to be a serverside script. here is my code:

local CMouse = require(script.CMouse)
while CMouse:GetPlayer() == nil do
    game:GetService("RunService").Stepped:wait()
end
UserInputService = game:GetService("UserInputService") --For left mouse click and others
local Player2 = game:GetService("Players").LocalPlayer
local mouse = Player2:GetMouse() --Error starts here
Players = game:GetService("Players")
plr = CMouse:GetPlayer() --getting all of the body parts. (R6)
char = plr.Character
hum = char:FindFirstChildOfClass'Humanoid'
local cam = game.Workspace.CurrentCamera --Getting the camera
Camera = cam
cam.CameraType = "Custom"
t = char.Torso
h = char.Head
ra = char["Right Arm"]
la = char["Left Arm"]
rl = char["Right Leg"]
ll = char["Left Leg"]
tors = char.Torso
lleg = char["Left Leg"]
root = char.HumanoidRootPart
hed = char.Head
rleg = char["Right Leg"]
rarm = char["Right Arm"]
larm = char["Left Arm"]
print(Players, plr, char, hum, cam, Camera, t, h, ra, la, rl, ll, tors, lleg, root, hed, rleg, rarm, larm, mouse) --Prints all of the stuff

What is wrong with my code and how can i fix it?

Edit: They (I) forgot CMouse was a property (existent) !

0
Sorry if the code is messy. Abacus300 7 — 3y
0
Always maintain your code in a code block, as it makes it easier for the community to analyse and follow your code. JesseSong 3916 — 3y

Answer this question