Im trying to make it so when you press W a GUI gets disabled but it says Expected ')' (to close '(' at line 2), got <eof>
i don't really understand scripting that well but i tried to fix it but couldn't
here is the script btw
local m = game.Players.LocalPlayer:GetMouse() m.KeyDown:connect(function(k) k = k:lower() if k == "w" then script.Parent.Fist.Enabled = false end end
i tried adding ) to all around the second line but wouldn't help
(the title is weird because i had to make it "specific")
the bracket is to close the Connect
local m = game.Players.LocalPlayer:GetMouse() m.KeyDown:Connect(function(k) k = k:lower() if k == "w" then script.Parent.Fist.Enabled = false end end)--here
I'm assuming you do not know this, but KeyDown and KeyUp are deprecated. This means it's old code which shouldn't be used, as it may be buggy or there are better options available.Read this article for more info. So, you may be asking, what do I use if they're deprecated? Simple, UserInputService. Here's an example of it:
game:GetService("UserInputService").InputBegan:connect(function(input) --When a key is pressed... if input.KeyCode == Enum.KeyCode.W then --Check if the key is W -- Do something when W is pressed! end end)
Now, i strongly recommend double checking your code for deprecated code, for example, :connect is deprecated too, instead use :Connect , with a capital C. Right, now we've got that over with let's mash your code and the new working code together:
game:GetService("UserInputService").InputBegan:connect(function(input)pressed... if input.KeyCode == Enum.KeyCode.W then script.Parent.Fist.Enabled = false --Change the boolean to False. end end)
For future reference:
Useful Links:
UserInputService, ContextActionService and getting user input.