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 » Scripters
Home Search
 

Re: 1st Person Gun Camera Movement Help

Previous Thread :: Next Thread 
MIntMushroom is not online. MIntMushroom
Joined: 04 Oct 2014
Total Posts: 3
02 Jul 2015 06:40 PM
I am a beginner with scripting and I need help with my gun script I made that makes the first person gun model follow the camera. The only issue is it doesn't have good smooth movement. And I don't know what to do to improve it. Here's the script.



local Gun = script.Parent
local Handle = Gun:WaitForChild("Handle")
local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local Mouse = Player:GetMouse()
local oldMouseHit = Mouse.Hit.p

function OnEquip()

local weld1 = Instance.new("Weld")
weld1.Parent = game.JointsService
weld1.C1 = Player.Character.Head.CFrame:toObjectSpace(Player.Character.Torso.CFrame)
weld1.Part0 = Player.Character.Torso
weld1.Part1 = Player.Character.Head

local weld2 = Instance.new("Weld")
weld2.Parent = Player.Character.Head
weld2.Part0 = Player.Character.Head
weld2.Part1 = Handle
weld2.C0 = CFrame.new(.7, -1.4, -1.7)

game:GetService("RunService").RenderStepped:connect(function()
weld1.C1 = CFrame.new(Player.Character.Head.CFrame.p,oldMouseHit):toObjectSpace(Player.Character.Torso.CFrame)
oldMouseHit = Mouse.Hit.p
end)
end
Gun.Equipped:connect(OnEquip)

Report Abuse
MIntMushroom is not online. MIntMushroom
Joined: 04 Oct 2014
Total Posts: 3
07 Jul 2015 01:44 AM
Help maybe?
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
07 Jul 2015 01:46 AM
You can make it first person by changing starterplayer properties for camera
Report Abuse
MIntMushroom is not online. MIntMushroom
Joined: 04 Oct 2014
Total Posts: 3
19 Jul 2015 05:02 PM
That's not what I wanted. I wanted the gun parented to the camera in first person. So when you look around the gun stays in the same spot on the screen. But thanks for that info.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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