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 » Game Design
Home Search
 

Re: How do I make an weapon that only shoots forward?

Previous Thread :: Next Thread 
cAoSbOx10 is not online. cAoSbOx10
Joined: 21 Nov 2012
Total Posts: 905
07 Nov 2016 06:51 AM
I've made a game with a top-view camera, and I want to add in weapons that only shoots to the direction the head is pointing. It may be easy to do, but I just want to learn how to.


- cAoS was here
Report Abuse
cAoSbOx10 is not online. cAoSbOx10
Joined: 21 Nov 2012
Total Posts: 905
07 Nov 2016 06:59 AM
Bump


- cAoS was here
Report Abuse
cAoSbOx10 is not online. cAoSbOx10
Joined: 21 Nov 2012
Total Posts: 905
07 Nov 2016 07:32 AM
Bump

SOMEONE HELP


- cAoS was here
Report Abuse
OnlySinister is not online. OnlySinister
Joined: 07 Jan 2015
Total Posts: 885
07 Nov 2016 08:01 AM
torso.lookVector
Report Abuse
cAoSbOx10 is not online. cAoSbOx10
Joined: 21 Nov 2012
Total Posts: 905
07 Nov 2016 08:15 AM
@Only
Tried to use it on a paintball gun. stopped working.

Tool = script.Parent

colors = {45, 119,#### ### ### ###,####}

function fire(v)

Tool.Handle.Fire:play()


local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local missile = Instance.new("Part")



local spawnPos = vCharacter.Head.lookVector



spawnPos = spawnPos + (v * 8)

missile.Position = spawnPos
missile.Size = Vector3.new(1,1,1)
missile.Velocity = v * 100
missile.BrickColor = BrickColor.new(colors[math.random(1, #colors)])
missile.Shape = 0
missile.BottomSurface = 0
missile.TopSurface = 0
missile.Name = "Paintball"
missile.Elasticity = 0
missile.Reflectance = 0
missile.Friction = .9

local force = Instance.new("BodyForce")
force.force = Vector3.new(0,90 * missile:GetMass(),0)
force.Parent = missile

Tool.BrickCleanup:clone().Parent = missile

local new_script = script.Parent.Paintball:clone()
new_script.Disabled = false
new_script.Parent = missile

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile



missile.Parent = game.Workspace

end



Tool.Enabled = true
function onActivated()

if not Tool.Enabled then
return
end

Tool.Enabled = false

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end

local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit

fire(lookAt)

wait(.5)

Tool.Enabled = true
end


script.Parent.Activated:connect(onActivated)


- cAoS was here
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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