Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use / as a key function?

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)

4 comments

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,.

0

.. I disabled the CoreGui, and people cant edit the coregui they can disable and build something that responds like it.

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

0

Use KeyUp, I got my MainFrame chat to work with that.

1 answer

✓ Accepted answer

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);

This discussion is preserved as it was. New answers, comments, and votes are closed.