Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how to make it so that when you press dot it prints?

Asked by 2 years ago
uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.Period then
        print("something")
    end
end)
0
this doesnt work btw mishokirva 22 — 2y
0
i know greatneil80 2647 — 2y
0
how do i make it work mishokirva 22 — 2y
0
The code looks good, make sure it's a localscript (if you wanted it client-sided) in starterplayerscripts JesseSong 3916 — 2y
View all comments (12 more)
0
its in a local script and it doesnt work mishokirva 22 — 2y
0
but i don't see the error JesseSong 3916 — 2y
0
check line 2, that may be the cause of the error(inputBegan) JesseSong 3916 — 2y
0
it works for other keys just not for period mishokirva 22 — 2y
0
post this on the dev forums because i don't know JesseSong 3916 — 2y
0
i cant post on devforum mishokirva 22 — 2y
0
that's the only way you can receive help. JesseSong 3916 — 2y
0
Bro thats literally the same mishokirva 22 — 2y
0
what? JesseSong 3916 — 2y
0
the guy that posted the answer mishokirva 22 — 2y
0
oh JesseSong 3916 — 2y

1 answer

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago
Edited 2 years ago

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.

0
you literally just changed the script JesseSong 3916 — 2y
0
Here is a devhub article about ContextActionService https://developer.roblox.com/en-us/api-reference/class/ContextActionService MattVSNNL 620 — 2y
0
In case you want to learn about contextactionservice MattVSNNL 620 — 2y
0
This doesn't always work JesseSong 3916 — 2y
View all comments (4 more)
0
Try putting it in StarterCharacter MattVSNNL 620 — 2y
0
I already know how to use localscripts, i placed it in startercharacterscripts,startgui, startplayerscripts and all localplayer containers JesseSong 3916 — 2y
0
what im saying is that it doesn't always work. i don't know if that's a roblox issue or smth. JesseSong 3916 — 2y
0
I might have to post this on the developer forums JesseSong 3916 — 2y
Ad

Answer this question