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: FPS gun

Previous Thread :: Next Thread 
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 04:52 PM
How would I make the gun follow the player's camera or whatever, like when you look upwards, then gun follows where you look?
I honestly can't figure it out.

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
21 Oct 2013 04:56 PM
I weld the arms to the head and whenever the mouse.Move event fires I adjust the head weld accordingly.
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 05:02 PM
Ok, so would I do somthing like

local function updateMove()

local Player = game.Players.LocalPlayer
local Char = Player.Character

w1 = Instance.new("ManualWeld", Char)
w2 = Instance.new("ManualWeld", Char)
w1.Part0 = Char.Head
w1.Part1 = Char["Left Arm"]
w2.Part0 = Char["Right Arm"]
w2.Part1 = Char.Head

MouseMoved:connect()

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
21 Oct 2013 05:09 PM
No do this

local weld = --newWeldHere

function updateWeld()
weld.C0 = --find angle here
end

mouse.Moved:connect(updateWeld)
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 05:11 PM
how do I find the angle? I'm never good with that kinda' stuff. =p

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 05:23 PM
atm I got:

local Player = game.Players.LocalPlayer
Player:GetMouse(mouse)
local weld = Instance.new("Weld", script.Parent)

function updateWeld()
weld.C0 = 0
end

mouse.Moved:connect(updateWeld)

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
InternetGuy is not online. InternetGuy
Joined: 28 Apr 2010
Total Posts: 3385
21 Oct 2013 05:26 PM
Well, after you figure out how to move your head,
Get the lookVector.
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 05:28 PM
now I got

local Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
local weld = Instance.new("Weld", script.Parent)
weld.Part0 = -- Would I do a player arm or the gun???
weld.Part1 = -- Would I do a player arm or the gun???

function updateWeld()
weld.C0 = mouse.Y
end

mouse.Moved:connect(updateWeld)

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 05:41 PM
and now:

local camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
local weld = Instance.new("Weld", script.Parent)

weld.Part0 = Player.Character["Left Arm"]
weld.Part1 = Player.Character["Right Arm"]

function updateWeld()
weld.C0 = mouse.Hit.p
end

mouse.Moved:connect(updateWeld)

the output says :
18:40:15.879 - Moved is not a valid member of PlayerMouse
... the mouse can't move? ...

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
AMDevelopment is not online. AMDevelopment
Joined: 09 Sep 2013
Total Posts: 84
21 Oct 2013 05:45 PM
maybe


Mouse.Changed



so it will happen whenever you do anything with the mouse. that is the idea, a constant update right?
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 05:48 PM
Ok, mouse.changed made no error in the output come up. c:
now I need to figure out all dat angle stuff.

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 06:47 PM
bump

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
reptoslicerguy is not online. reptoslicerguy
Joined: 01 Jan 2010
Total Posts: 2098
21 Oct 2013 06:54 PM
hmm.
maybe i'll give it a shot.
only because i would like to start learning scripting guns/animations soon too xD
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 07:00 PM
Nope, Can't figure out the angle stuff, or how to "move the head and get then look vector"

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
21 Oct 2013 07:42 PM
bump

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
24 Oct 2013 05:45 PM
bump

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Oct 2013 05:46 PM
Edit the joints in torso according to the camera
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
24 Oct 2013 05:50 PM
how? I'm not really sure.

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Oct 2013 05:52 PM
Using CFrame Angles and unit vectors
Report Abuse
blocker192 is not online. blocker192
Joined: 13 Jan 2010
Total Posts: 496
24 Oct 2013 05:55 PM
I spent months trying to figure this out. To tell you the truth, I don't even want to give the secret up.
Report Abuse
drahsid5 is not online. drahsid5
Joined: 13 May 2011
Total Posts: 3937
24 Oct 2013 05:55 PM
No dip. I'm not sure how I'd do that in the script, exactly.

When life gives you lemons, Squirt 'em in your eyes. - Drahsid5
Report Abuse
uptightwertman123 is not online. uptightwertman123
Joined: 11 Mar 2012
Total Posts: 913
24 Oct 2013 06:18 PM
Hi,
Could someone here give me the script for a gun with multiple brick parts be able to move to all angles?
I already have the one that works with mesh guns.
Report Abuse
xXIcanthinkofanameXx is not online. xXIcanthinkofanameXx
Joined: 05 May 2012
Total Posts: 857
24 Oct 2013 06:25 PM
Use trigonometry to determine the angle.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Oct 2013 06:27 PM
^ you can use atan2 for what you want
Report Abuse
uptightwertman123 is not online. uptightwertman123
Joined: 11 Mar 2012
Total Posts: 913
24 Oct 2013 06:36 PM
I don't know that trigionometry is and, most importantly, how to script...
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