|
| 02 Jul 2012 09:21 PM |
I want to decrease the FieldOfView by 1 when q is pressed, all the way to 20. How would I add this to my script using math, or some other way?
local player = Game.Players.LocalPlayer local keyFunctions={ ["q"]=function() --fieldofview should go here I think. end; } script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower() if keyFunctions[key] then keyFunctions[key]() end end) end)
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:25 PM |
Seriously? No one knows this?
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:29 PM |
._.
Knightmare, this is where you come in...
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:35 PM |
Damn, SH. Answer already ._.
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:37 PM |
--FieldOfView is a Player Property right?
local player = game.Players.LocalPlayer local fov = player.FieldOfView
local keyFunctions={ ["q"]=function() if (fov > 20) then fov = fov - 1 end end; } script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower() if keyFunctions[key] then keyFunctions[key]() end end) end)
|
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:39 PM |
-- Or was it a Camera Property.....
local player = game.Players.LocalPlayer local cam = workspace.CurrentCamer
local keyFunctions={ ["q"]=function() if (cam.FieldOfView > 20) then cam.FieldOfView = cam.FieldOfView - 1 end end; } script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower() if keyFunctions[key] then keyFunctions[key]() end end) end) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:39 PM |
Actually it's under the Camera object in Workspace.
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:40 PM |
Sorry, I haven't done FOV for alittle bit.
Use my Second Script There. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:44 PM |
I keep getting a weird-o output:
Players.Player.Backpack.PaintballGun.onKeyDown:15: '=' expected near 'end' 22:42:38 - Players.Player.Backpack.PaintballGun.onKeyDown:15: '=' expected near 'end' Here's the script:
local player = game.Players.LocalPlayer local cam = workspace.CurrentCamera local keyFunctions={ ["q"]=function() if (cam.FieldOfView > 20) then cam.FieldOfView = cam.FieldOfView - 1 end end; } script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower() if keyFunctions[key] then keyFunctionskey end end) end)
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:48 PM |
:\
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:54 PM |
local player = game.Players.LocalPlayer local cam = workspace.CurrentCamera local keyFunctions={ ["q"]==function() if (cam.FieldOfView > 20) then cam.FieldOfView = cam.FieldOfView - 1 end end; } script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower() if keyFunctions[key] then keyFunctions[key] end end) end)
--Maybe? |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 09:57 PM |
| Im fixing right now, but what is with the open ended "keyFunctionskey"? I'm just going to make my own right now... Hold tight for a sed :/ |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:01 PM |
Oh, I made that mistake a while ago and forget to fix it :P
I'm using an old model of a template for onkeyDowns I made myself. But I made an error writing it and never got to updating the model. Now it works, but it doesn't change the camera for some reason...
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:01 PM |
And by that I mean no output, but the FieldOfView never changes when I press "q".
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:02 PM |
Honestly, I just don't like your keydown scripts, greenday. Here:
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower()
if key == "q" then if cam.FieldOfView>20 then cam.FieldOfView = cam.FieldOfView - 1 end end
end) end)
|
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:04 PM |
Whoops, forgot the variable :P
local player = game.Players.LocalPlayer local cam = workspace.CurrentCamera
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower()
if key == "q" then if cam.FieldOfView>20 then cam.FieldOfView = cam.FieldOfView - 1 end end
end) end) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:06 PM |
| This is my first day trying to learn how to script and I see this! Sketchy stuff! Hahaha! :/ |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:06 PM |
It only decreases the field of view by 1, every time I press q though. I want it to go all the way to 20 by itself, in 1 press.
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:08 PM |
then: cam.FieldOfView = 20
Honestly greenday? |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:08 PM |
I mean, decrease from 75 to 20, by 1 at a time ._.
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:09 PM |
| Lemme guess... Sniper scope? |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:09 PM |
local player = game.Players.LocalPlayer local cam = workspace.CurrentCamera
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower()
if key == "q" then while cam.FieldOfView>20 do wait(.5) cam.FieldOfView = cam.FieldOfView - 1 end end
end) end) |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:09 PM |
My siggy gave it away, didn't it? XD
I was going to use cam manipulation, but crazyman32 said to use FieldOfView o.o
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:13 PM |
@captain
Your script made it move really skip-frame like, so I changed the wait to 0.1, but it still doesn't look very smooth. How would I fix that? Also, how would I make it go back to normal when q is pressed again?
-GD987, the FPS Developer- |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2012 10:14 PM |
local player = game.Players.LocalPlayer local cam = workspace.CurrentCamera
script.Parent.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) local key=key:lower()
if key == "q" then while cam.FieldOfView>21 do wait(.05) cam.FieldOfView = cam.FieldOfView - 1 end end
end) end)
That looks smoother for me :D |
|
|
| Report Abuse |
|
|