I have a localscript, and the first line is getmousething()
. Later in the script, I have:
function getmousething() local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key.Byte == 102 then print 'F presseed' end end) end
The error message is attempt to call global 'getmousething' (a nil value)
. Why can't it find that function?
This might fix it.
function getmousething() local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key.Byte == 102 then print 'F presseed' end end) end getmousething() -- Roblox must read the function before having it be called. --You said that you ran it before it was called, Like above the function which would have been the error you got.
Roblox reads or loads everything in a script from Top to Bottom. So if your first line of Code is the call for the function, It hasn't read the function yet so it calls an error.
Try putting your call right under the function, or at the very bottom of the script.