What is wrong with this Script. Is it because I'm using the GetMouse
event or is it because of line 6?
open = script,Parent function KeyDown(key) local key = key:lowerkey() if key == "e" then game.StarterGui.sttngpg.plrstats.Visible = true end end open.Parent.plrstats:GetMouse().KeyDown:connect(KeyDown)
please Help!
Your problems are lines 4, and 6: On line 4, lowerkey
is not a valid Method, consider changing to key:lower()?
, and, on line 6, you are only changing the StarterGui's GUI
version, lastly, there is another two problems I am noticing; Lines 6 and the last Line; You do not need to use that much code, the more problems with two codes are; What if they do not exist? Then what? What can I do to prevent this?
, this can also be fixed, however, it will require using the WaitForChild Method. Now that I have pointed out all these problems, lets fix your code;
local open = script.Parent local plrstats = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("plrstats") --This looks much cleaner, doesn't it? ;) local plrstats2= game.Players.LocalPlayer:GetMouse() --This looks much cleaner, doesn't it? ;) function KeyDown(key) local key = key:lower() if key == "e" then plrstats.Visible = true end end plrstats2.KeyDown:connect(KeyDown)
Ah, now doesn't your code looks allot better, and cleaner? :) Hope this helped!
First: It's not:
local key = key:lowerkey()
Change it for:
local key = key:lower()
And continue making the script <3