I don't want the player not to be able to go backwards only forwards but my code isn't working.

(Output) : ServerScriptService.script:1: attempt to index a nil value

My code:

local Hum = game.Players:GetPlayerFromCharacter(nil).Character.HumanoidRootPart

  

while true do

if Hum.Orientation == Hum.Orientation.Unit(0, 163.57, 0) or Hum.Orientation == Hum.Oriention.Unit(0, 54.64, 0) then

Hum.Orientation = Hum.Orientation.Unit(0, 0, 0)

wait(0.1)

end

end

5 comments

0

I think you should force their camera face forward and make the back button s nil

0

+extremeparkrider I would make the camera attached and to not be able to use the "s" key you use userinputservice??

0

I wouldn't recommend usi it is really complicated right now I am trying to learn how it's done myself will get back to you I've come as for as context action service but filtering enabled places also pose another layer of learning barrier e.e

0

as far as my research we may need to negate the action of back through a control script but I could be wrong

0

I have seen people use a input code and have walkspeed in humanoid set to zero on every s key and walkspeed normal every other event. sorry for my bad english.