generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: FieldOfView question.

Previous Thread :: Next Thread 
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
02 Jul 2012 09:25 PM
Seriously? No one knows this?





-GD987, the FPS Developer-
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
02 Jul 2012 09:29 PM
._.

Knightmare, this is where you come in...




-GD987, the FPS Developer-
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
02 Jul 2012 09:35 PM
Damn, SH. Answer already ._.




-GD987, the FPS Developer-
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
02 Jul 2012 09:39 PM
Actually it's under the Camera object in Workspace.





-GD987, the FPS Developer-
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
02 Jul 2012 09:40 PM
Sorry, I haven't done FOV for alittle bit.

Use my Second Script There.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
02 Jul 2012 09:48 PM
:\




-GD987, the FPS Developer-
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
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
TurtlePunch is not online. TurtlePunch
Joined: 26 Jun 2012
Total Posts: 726
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
02 Jul 2012 10:08 PM
then: cam.FieldOfView = 20

Honestly greenday?
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
02 Jul 2012 10:08 PM
I mean, decrease from 75 to 20, by 1 at a time ._.




-GD987, the FPS Developer-
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
02 Jul 2012 10:09 PM
Lemme guess... Sniper scope?
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
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
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image