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

How do I fix my Keycode is not a valid EnumItem?

So I was trying to get this permadeath system to work but when I said ":PD ON" it kept giving me an error in game

--:PD ON Is not a valid EnumItem
Stack Begin
Script Players.enacent00.PlayerGui.PDUI.Toggle , Line 9
Stack End

This is the code in the script

local GroupID = 4327198
local MinRank = 230

local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local Bind = ":PD ON"

UIS.InputBegan:Connect(function(K,T)
	if K.KeyCode == Enum.KeyCode[Bind] and not T then
		
		if Player:GetRankInGroup(GroupID) >= MinRank or Player.Name == "YnwRash" or Player.Name == "enacent00"then
		
		if script.Parent.Enabled == true then
			script.Parent.Enabled = false
		elseif script.Parent.Enabled == false then
			script.Parent.Enabled = true
		end
			
			end
	end
end)

9 comments

0

What do you want the script to do http:/xyproblem.info

0

Its supposed to toggle the PDUI on and off

0

how is it supposed to toggle

0

Line 13 to 16

0

The Main Issue is line 9 because the KeyCode Binded doesn't work

0

how is it supposed to toggle

0

By me saying :PD ON

0

in the chat?

1 answer

✓ Accepted answer

Try the following:

local GroupID = 4327198
local MinRank = 230

local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local Bind = ":PD ON"

local Admins = {YnwRash = true, enacent00 = true} -- Define admins

Player.Chatted:Connect(function(Message)
	if Message == Bind then -- If the message is the same
		if Player:GetRankInGroup(GroupID) >= MinRank or Admins[Player.Name] then -- Detect if player is an admin or is in group
			script.Parent.Enabled = not script.Parent.Enabled -- Disable/Enable the gui
		end
	end
end)

4 comments

0

Player:GetRankInGroup is server-script only

0

also Admins[Player.Name] returns nil

0

Player:GetRankInGroup was in the original script

0

Also it was supposed to return nil. Maybe understand the question before downvoting?

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