Can't get SetEyeAngles to work so it limits a player's view

So, I opened an old addon that I was doing like 2 years ago and I tried to make it work and I’ve been trying to get this working but I don’t know how to limit a player’s view, make them only see from 0° to 90° to the right when “ply.something = true” and 90° to 0° to the left when “ply.something2 = true”.
I just cant get this working and this is really stressing me out.
Could any of you guys give me hand?
Thanks

Some code might help

Edit: Im wrong!

He’s not trying to block half the view, he’s trying to clamp the view between two angles

[editline]30th April 2016[/editline]

Try using a hook like

GM:Tick (but maybe one that runs a little faster), then use

Entity:EyeAngles to get the current eye angles of the player, then use

Player:SetEyeAngles to set the angles as the previous angles that were gotten, but make sure to use something like

math.Clamp to clamp the yaw of the angle

E.G.



hook.Add( 'Tick', 'ClampView', function()

	local ang = LocalPlayer():EyeAngles()
	
	LocalPlayer():SetEyeAngles( Angle( ang.p, math.Clamp( ang.y, 0, 90 ), ang.r ) )

end )


The only problem with that code is that I don’t know how to properly clamp the yaw so it gets clamped to the left or the right, but some math god will probably stumble across this thread and tell you at some point

Ahhh I see what you mean, interpreted the op wrong my bad. :smile:

This would theoretically work if he really wanted the 0 and 90 angles, but how can you know those are the exact angles that will fit your needs?

He can adjust them?? That should give him the concept he needs to finish the rest himself

I think you misunderstood - Those angles might work at one part/area of the map, but not the other

I definitely use InputMouseApply to modify viewangles on the client.

Good point, but it sounds like hes capable of doing the rest himself. I’m not trying to be a dick, but I don’t think that straight up spoon feeding will help him in the long run either