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

Help with keyboard press finding Character, nil Value?

Asked by 7 years ago

I need this script to find the Player's Character, but it always says:

18:41:52.896 - Players.TinyScripter.PlayerScripts.KeyboardControls:11: attempt to index upvalue 'Face' (a nil value)
18:41:52.897 - Stack Begin
18:41:52.898 - Script 'Players.TinyScripter.PlayerScripts.KeyboardControls', Line 11
18:41:52.899 - Stack End

Here is the script:

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
local UserInputService = game:GetService("UserInputService")
local NewFa = game.Players.LocalPlayer.NewFa
local Face = game.Players.LocalPlayer.Character
function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.F then

    if NewFa.Value == false then
    NewFa.Value = true
    Face.Head.face.Transparency = 1
    local Facez = Face.Head.face:Clone()
    Facez.Transparency = 0
    Facez.Name = "facez"
    Facez.Image = ("rbxassetid://918741416")
    else
        NewFa.Value = false
        Face.Head.face.Transparency = 0
        Face.Head.facez:Destroy()
    end
end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Answer this question