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

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

Asked by 3 years ago

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)
0
What do you want the script to do http:/xyproblem.info User#30567 0 — 3y
0
Its supposed to toggle the PDUI on and off Plexiious 5 — 3y
0
how is it supposed to toggle User#30567 0 — 3y
View all comments (5 more)
0
Line 13 to 16 Plexiious 5 — 3y
0
The Main Issue is line 9 because the KeyCode Binded doesn't work Plexiious 5 — 3y
0
how is it supposed to toggle User#30567 0 — 3y
0
By me saying :PD ON Plexiious 5 — 3y
0
in the chat? User#30567 0 — 3y

1 answer

Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your 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)
0
Player:GetRankInGroup is server-script only Leamir 3138 — 3y
0
also Admins[Player.Name] returns nil Leamir 3138 — 3y
0
Player:GetRankInGroup was in the original script User#30567 0 — 3y
0
Also it was supposed to return nil. Maybe understand the question before downvoting? User#30567 0 — 3y
Ad

Answer this question