Help, the 'SetCore' function isn't working when a Certain Enum KeyBind is clicked

What I’m trying to make is a Message that the Server will send once a KeyBind is clicked on the players keyboard.

But there’s an issue, when I add ‘if input == Enum.KeyCode.E’ it won’t print or do anything, instead it just sits there with no errors in the output. But when I remove the If statement in the script, when you do anything it works (as it should).

Added If Statement (Clicked btw):
dead
No If Statement (Clicked btw):
dead2

I looked on the DevForum and couldn’t find anything, absolutely nothing. I tried to add it into a regular script, not a local and as it should, it wouldn’t work because you can’t set CoreGui in a Regular script.

Here’s my script:

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local starterGui = game.StarterGui
UIS.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	if input == Enum.KeyCode.P then
		starterGui:SetCore("ChatMakeSystemMessage", {
			Text = "Test";
			Color = Color3.fromRGB(255, 255, 255);
			Font = Enum.Font.SourceSansBold;
			FontSize = Enum.FontSize.Size32;
		})
		print("A")
		else
	end	
end)

Please help me, I am really desperate for this to work LOL.

It should work now.

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local starterGui = game.StarterGui
UIS.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	if input.KeyCode == Enum.KeyCode.P then --// Added .KeyCode here
		starterGui:SetCore("ChatMakeSystemMessage", {
			Text = "Test";
			Color = Color3.fromRGB(255, 255, 255);
			Font = Enum.Font.SourceSansBold;
			FontSize = Enum.FontSize.Size32;
		})
		print("A")
		else
	end	
end)

Thank you, Roblox isn’t letting me reply or something because of an error or something so I’m just shortening it right now. It works, what was I missing? Nvm I see it, Thank you lol I totally forgot .KeyCode had existed

You should use the new TextChatService.

Okay, I’ve never tried it before so I’ll make sure to check it out

Yeah. The API is way easier and has arguably better features. Take a look at the docs.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.