How to give more speed to my entity when i'm using the forwardkey?

How to give more speed to my entity when i’m using the forwardkey?

In fact, I want to make my entity accellerate when i’m typing the forwardkey

Maybe use shift like vehicles?

sure, but i don’t know how to code it… i want to make something like that… if player use shift add 10 to the current speed and that until it reach the maximum value

I don’t know how to code either, but maybe “addspeed 10?” or something?

Please, Please, PLEASE Dont make guesses like that. That is not even remotely Lua.

it may help if we had your code so we could see what we were working with

[lua]AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(“shared.lua”)

function ENT:SpawnFunction( ply, tr)
local SpawnPos = tr.HitPos + tr.HitNormal * 60
local ent = ents.Create( “Harrier” )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end

function ENT:Initialize()

 self.Entity:SetModel("models/katharsmodels/vipermk2/vipermk2_shuttle.mdl")
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_NONE )
self.Entity:SetSolid( SOLID_VPHYSICS )
    
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
    phys:Wake()	
end
self.Entity:StartMotionController()

self.Entity:SetUseType( SIMPLE_USE )

self.User = nil

end

function ENT:Use(ply, cal)
if !self.InUse then
self.InUse = true
self.User = ply

	ply:Spectate( OBS_MODE_CHASE )
	ply:DrawViewModel(false)
	ply:DrawWorldModel(false)
	ply:StripWeapons()
	ply:SetPos(self.Entity:GetPos())
	self.Entity:GetPhysicsObject():Wake()
	self.Entity:GetPhysicsObject():EnableMotion(true)

end
end

function ENT:Think()

if not ValidEntity(self.User) then
	self.User=nil
end

if ValidEntity(self.User) and self.InUse then
if self.User:KeyDown(IN_USE) then

self.User:UnSpectate()
self.User:DrawViewModel(true)
self.User:DrawWorldModel(true)
self.User:Spawn()
self.User:SetPos(self.Entity:GetPos()+Vector(0,100,100))

		self.Entity:SetLocalVelocity(Vector(0,0,0))
		self.User=nil
		self.InUse = false
		end	

–controls

if self.User then

if self.User:KeyDown(1) then

// Get the shot angles and stuff.
local angles = self.Entity:GetAngles()
local shootAngles = angles
local shootOrigin = self.Entity:GetPos()
local shootDir = shootAngles:Forward()

  local bullet = {}
		bullet.Num 			= 2
		bullet.Src 			= shootOrigin 
		bullet.Dir 			= shootDir 
		bullet.Spread 		= Vector(0.165,0.165,0)
		bullet.Tracer		= 1
		bullet.TracerName 	= "HelicopterTracer"
		bullet.Force		= 10
		bullet.Damage		= 18
		bullet.Attacker 	= self.User		
	self.Entity:FireBullets( bullet )

end

if self.User:KeyDown(8) then
phys:AddVelocity( self.Entity:GetForward() * 100 ) --Add 100 to the initial speed?
end

if self.User:KeyDown(1024) then

self.lin = Vector(0,0,0)
self.ang = Vector(0,0,0)
local forcelinear, forceangular = phys:CalculateForceOffset(self:GetUp() * 20, self:GetPos() + self:GetRight() * 20) //First arguement is the vector force, second is the origin of the force.

//self.lin = forcelinear + self.lin Dont apply linear you just want it to roll
self.ang = forceangular + self.ang

return self.ang, self.lin, SIM_GLOBAL_ACCELERATION
end

if self.User:KeyDown(512) then
self.lin = Vector(0,0,0)
self.ang = Vector(0,0,0)
local forcelinear, forceangular = phys:CalculateForceOffset(self:GetUp() * 20, self:GetPos() + self:GetRight() * -20) //First arguement is the vector force, second is the origin of the force.

//self.lin = forcelinear + self.lin Dont apply linear you just want it to roll
self.ang = forceangular + self.ang

return self.ang, self.lin, SIM_GLOBAL_ACCELERATION
end
end
end
end

function ENT:PhysicsSimulate( phys, deltatime )

if self.User then

phys:Wake()

local Pos = self.Entity:GetPos()
local ang = self.User:GetAimVector():Angle()
local Forward = self.Entity:GetForward() * 350 --InitialSpeed

   self.ShadowParams={}
	self.ShadowParams.secondstoarrive = 1
	self.ShadowParams.pos = Pos + Forward
	self.ShadowParams.angle = ang
	self.ShadowParams.maxangular = 5000
	self.ShadowParams.maxangulardamp = 10000
	self.ShadowParams.maxspeed = 1000000
	self.ShadowParams.maxspeeddamp = 10000
	self.ShadowParams.dampfactor = 0.8
	self.ShadowParams.teleportdistance = 0
	self.ShadowParams.deltatime = deltatime
phys:ComputeShadowControl(self.ShadowParams) 

end
end
[/lua]