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

How to use / as a key function?

Asked by 10 years ago

I am making custom chat, I tested everything it works with the enter button as the fire on the KeyDown() but I want it to be / but when I have it set it works in studio but not in player...

heres the script if you need it

wait(.5)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local able = false
local default = script.Default

function ondown(key)
    if key:byte() == 13 and able == false
    then
    able = true
        script.Parent:TweenSizeAndPosition(UDim2.new(1,0,.05,0), UDim2.new(0,0,.45,0), "Out", "Quad", .5, true)
        script.Parent.TextXAlignment = "Center"
        script.Parent:CaptureFocus()
    end
end

function clear(e)
    if e == true
        then
        game.Workspace.Fabrication_Framework.CoreGui_Script.Chat.RemoteFunction:InvokeServer(script.Parent.Text)
        print("Sent")
    end
    script.Parent:TweenSizeAndPosition(UDim2.new(1,0,.025,0), UDim2.new(0,0,.975,0), "Out", "Quad", .5, true)
    script.Parent.TextXAlignment = "Left"
    able = false
    script.Parent.Text = default.Value
end

script.Parent.FocusLost:connect(clear)
mouse.KeyDown:connect(ondown)
0
This is tricky, considering it is a CoreGUI. I'm not sure if it even is possible to create a keyDown function from /, I think people somehow change the CoreGUI to their suiting by simply changing the GUI look. Try looking into it some more,. SlickPwner 534 — 10y
0
.. I disabled the CoreGui, and people cant edit the coregui they can disable and build something that responds like it. User#5978 25 — 10y
0
I've searched the Wiki thoroughly, and the closest it get to a "/" is by listing special characters. I doubt this is any help, but maybe you could use it for future reference http://wiki.roblox.com/index.php?title=Special_Characters Shawnyg 4330 — 10y
0
Use KeyUp, I got my MainFrame chat to work with that. M39a9am3R 3210 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

Alright, to everyone saying you can't use '/' in a key. Actually you can, using UserInputService. No offense intended, just stating a fact. Also, here's the code to use it.

game:service'UserInputService'.InputBegan:connect(function(input)
if not(input.UserInputType == Enum.UserInputType.Keyboard) then return end;
if not(input.KeyCode == Enum.KeyCode.Slash) then return end;
--code
end);
Ad

Answer this question