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
 

How do I...

Previous Thread :: Next Thread 
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 05:15 PM
I want to make a hyperlaser shotgun with accuracy. Where do I add the math.randoms to change accuracy so the shots all go different places?
All the variables and functions were defined earlier so you don't have to sift through them.

local function OnActivated()
for i=1, SHOT_NUMBER do
if Tool.Enabled and Humanoid.Health > 0 then
Tool.Enabled = false

FireSound:Play()

local handleCFrame = Handle.CFrame
local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)

local laserShotClone = BaseShot:Clone()
laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
local bodyVelocity = Instance.new('BodyVelocity')
bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
bodyVelocity.Parent = laserShotClone
laserShotClone.Touched:connect(function(otherPart)
OnTouched(laserShotClone, otherPart)
end)
DebrisService:AddItem(laserShotClone, SHOT_TIME)
laserShotClone.Parent = Tool

--wait(0.6) -- FireSound length



Tool.Enabled = true
end
end
end
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 05:37 PM
I know it's a little early for a bump, but I'm the only viewing this thread. Help please?
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 05:59 PM
Bump, again.
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 06:12 PM
Bump, again, again.
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 06:54 PM
Bump, again, again, again.
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 07:56 PM
Bump, again, again, again, again.
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
27 Nov 2013 08:02 PM
Where ever your mouse is pointing you should do:
.Position+Vector3.new(math.random(-1, 2), math.random(-1,1), math.random(-1, 1))

-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ --
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 08:04 PM
Thank you for a response at last!
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
27 Nov 2013 08:07 PM
I'm not too 'knowledgeful' or experienced with RayCasting or anything to do with Mouses but I'm pretty sure that should work.

-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ --
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
27 Nov 2013 08:09 PM
What the person above said will make any time your mouse is on a close object, you have horrible accuracy, and when you have the mouse on a far away object, it is really accurate. To solve this, i'd do something like:

vel = (mouse.Position-char.Torso.Position).unit

vel = vel + Vector3.new(math.random(-10,10)/20,math.random(-10,10)/20,math.random(-10,10)/20)

Which will make it just as accurate at all ranges.
Report Abuse
2DB is not online. 2DB
Joined: 18 Nov 2013
Total Posts: 109
27 Nov 2013 08:49 PM
Thanks guys!
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