Hi everybody, so i know they replaced the keydown thing and there is no more getmouse().keydown stuff, but imade a HUGE script:
local UIS = game:GetService("UserInputService") can = true UIS.InputBegan:connect(function(input) if can == true then can = false *[this content was supposed to be the real script but this might be copied and someone might use it in the game they make and i dont want that especialy when you cant track those people, since this is a SCRIPT! and they can take my name out easily, so this content has been deleted, sorry]* can = true end end)
and the thing is this does all this stuff when key pressed, i have debug yes its helpful, but i cant seem to have the specific keydown thing working, i took it out because i wanted to focus on waht the script actualy does so i dont waste a lot of time just on the keydown thing, but yeah i tried, it doesnt work i could be doing it wrong.., no debug, so this script since taken out specific key thing, when you press anything or click, this script works, for the actual action, so how can i make the server sense what key it specificaly is? and btw sorry grammer might be wrong but im hurrying because i have to go to a party! Anyone feel free to edit this to fix grammar. Thanks! :)
There are several ways to do this. One can use UserInputService in order to accomplish this, another way is ContextActionService, and mouse.KeyDown, but I'm only going to tell you UserInputService and ContextActionService
When using UserInputService, I'd recommend using a variable to define it, and then connecting it to an InputBegan function
local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, typing) if input.KeyCode == Enum.KeyCode.W and not typing then --What happens when they're holding W end end)
and then you have to close it off with the InputEnded
local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, typing) if input.KeyCode == Enum.KeyCode.W and not typing then --What happens when they're holding W end end) UIS.InputEnded:Connect(function(input, typing) if input.KeyCode == Enum.KeyCode.W and not typing then --What happens when they finished holding W end end)
Now for ContextActionSerivce store it in a variable, then bind the action
local Context = game:GetService("ContextActionService") local functionR = function(actionName, actionInputState, actionInputObject) if actionInputState == Enum.UserInputState.Begin then --What happens when holding w end end Context:BindAction( "actionName", functionR, false, -- Makes a button on their screen(mobile) "w" -- The button they need to press on Pc )
Also, mouse.KeyDown() is deprecated, please do not use it.
I hope I helped!
Hello, i dont know why but i just like answering these guy's questions- anyways i think i know the PROBLEM, so first things first, it may be you're device or it can be you're studio, and if you didnt know, studio is NOT the same as normal roblox player, so things can work in studio but not in roblox normal game, or vise versa, so instead of using studio to test it, teast actualy PLAYING YOUR GAME, remember; you dont need to have a game thats not private, it can be private, butthe owner will always be able to play it, later ill come back :)