I'm trying to edit the control scheme for a tank turret so that instead of the usual WASD its IJKL. Below is the script that both fires and aims/rotates the tank.
repeat wait() until script.Parent.Parent.Vehicle.Value~=nil db=false held=false v=script.Parent.Parent.Vehicle f=script.Parent missile=script.Parent.HE function fireguns() v1=v.Value.Gun1Bullet:clone() vel=Instance.new("BodyVelocity") vel.Parent=v1 v1.Velocity=v1.CFrame.lookVector*200 vel.velocity=v1.Velocity v1.CanCollide=true vel.maxForce = Vector3.new(0,710,0) v1.Transparency=0 v1.Damage.Disabled=false v1.Parent=workspace end function launchmissile() v.Value.Effect.Smoke.Enabled = true v.Value.Effect.Fire:Play() v.Value.Effect.Transparency = .5 v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 - Vector3.new(0,0, .5) v1=v.Value.Missile:clone() v1.CFrame = v.Value.Missile.CFrame * CFrame.new(0, 0, -5) vel=Instance.new("BodyVelocity") vel.Parent=v1 v1.Velocity=v1.CFrame.lookVector*200 vel.maxForce = Vector3.new(0,710,0) vel.velocity=v1.Velocity v1.CanCollide=true v1.Transparency= 0 v1.Heat.Disabled=false v1.Parent=workspace wait(.1) v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1) v.Value.Effect.Transparency = .6 wait(.1) v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1) v.Value.Effect.Transparency = .7 wait(.1) v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1) v.Value.Effect.Transparency = .8 wait(.1) v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1) v.Value.Effect.Transparency = .9 wait(.1) v.Value.WER2.Value.C0 = v.Value.WER2.Value.C0 + Vector3.new(0,0, .1) v.Value.Effect.Transparency = 1 v.Value.Effect.Smoke.Enabled = false wait(3) end function missileclick() print("click missile") if db==true then return end db=true missile.Text="Reloading" launchmissile() v.Value.Effect.Reload:Play() wait(5) missile.Text="Fire HE" v.Value.Effect.Reload:Stop() db=false end function gunsdown() held=true while held==true do fireguns() wait() end end function gunsup() held=false print("up") end missile.MouseButton1Click:connect(missileclick) sabot.MouseButton1Click:connect(sabotclick) guns.MouseButton1Down:connect(gunsdown) guns.MouseButton1Up:connect(gunsup)