uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Period then
print("something")
end
end)
how to make it so that when you press dot it prints?
1 answer
The problem is the dot is already a key to turn right, So it won't do anything, Try this
local contextActionService = game:GetService("ContextActionService")
function onPressed()
print("Pressed!")
end
contextActionService:BindAction("print", onPressed, false, Enum.KeyCode.Period)
Also put it in StarterGui
The reason why your script wasn't working is the dot is already a bind action to turn right with userinputservice it can't overwrite the action, So with ContextActionService we are overwriting the bind action of the dot so it will work, Also turn it to true if you want to make a mobile button of it.
8 comments
you literally just changed the script
Here is a devhub article about ContextActionService https://developer.roblox.com/en-us/api-reference/class/ContextActionService
In case you want to learn about contextactionservice
This doesn't always work
Try putting it in StarterCharacter
I already know how to use localscripts, i placed it in startercharacterscripts,startgui, startplayerscripts and all localplayer containers
what im saying is that it doesn't always work. i don't know if that's a roblox issue or smth.
I might have to post this on the developer forums
This discussion is preserved as it was. New answers, comments, and votes are closed.

16 comments
this doesnt work btw
i know
how do i make it work
The code looks good, make sure it's a localscript (if you wanted it client-sided) in starterplayerscripts
its in a local script and it doesnt work
but i don't see the error
check line 2, that may be the cause of the error(inputBegan)
it works for other keys just not for period
post this on the dev forums because i don't know
https://devforum.roblox.com/
i cant post on devforum
that's the only way you can receive help.
Bro thats literally the same
what?
the guy that posted the answer
oh