So, I am trying to code some script that i forgot i had a long time ago and I keep on getting the error: "Workspace.InfOHac.fur:1486: attempt to index nil with 'InputBegan'". and it is annoying me a lot, my code is
UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(io, gpe, input, gameProcessed) if(gpe or Attack)then return end if(io.KeyCode==Enum.KeyCode.Q)then Personality=Personality-1 if(Personality<1)then Personality=5 end elseif(io.KeyCode==Enum.KeyCode.E)then Personality=Personality+1 if(Personality>5)then Personality=1 end elseif(io.KeyCode==Enum.KeyCode.Semicolon)then ManualMode=true elseif(io.KeyCode==Enum.KeyCode.R)then ChangeStance'Sit' elseif(io.KeyCode==Enum.KeyCode.F)then ChangeStance'Auto' end end)
Can someone help me because it is getting me really annoyed and I don't know how to fix it.
Sorry if it is unreadable
Edit: Yes i did define UserInputService
Try using this bit of code for detecting input instead:
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input, busy) if busy then return end if input.KeyCode == Enum.KeyCode.E then print("E") elseif input.UserInputType == Enum.UserInputType.MouseButton1 then print("Left Click") end end)