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: Can someone make this shoot in a shotgun-like fashion?

Previous Thread :: Next Thread 
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Feb 2012 06:14 PM
:3

originalAmmo = script.Parent.Ammo.Value
m = Instance.new("Message")

function computeDirection(vec)
local lenSquared = vec.magnitude^2
local invSqrt = 1 / math.sqrt(lenSquared)
return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end



function updateAmmo()
m.Text = " "
--for i = 1,script.Parent.Ammo.Value do
-- m.Text = m.Text .. "|"
--end
--for i = 1, (originalAmmo - script.Parent.Ammo.Value) do
-- m.Text = m.Text .. " "
--end
m.Text = m.Text .. " " .. script.Parent.Ammo.Value.. "/10"
end


function fire(v)
for i = 1,1 do
script.Parent.Handle.Fire:play()
script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
updateAmmo()

local dir = v - script.Parent["Handle"].Position
dir = computeDirection(dir)

local pos = script.Parent["Handle"].Position + (dir * 6)

local p = Instance.new("Part")
p.Name = "Projectile"
p.CFrame = CFrame.new(pos, pos + dir)
p.BrickColor = BrickColor.new(21)
p.Reflectance = 0.1
p.Velocity = (script.Parent.Parent["Head"].Position - v).unit * -150
p.Size = Vector3.new(1, 0.4, 1)
p.formFactor = 2

local mesh = script.Parent.Mesh:clone()
mesh.Parent = p

local upforce = Instance.new("BodyForce")
upforce.force = Vector3.new(0, p:GetMass() * 196, 0)
upforce.Parent = p

local creator = Instance.new("ObjectValue")
creator.Name = "creator"
creator.Value = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
creator.Parent = p

local s = script.Parent["ProjectileScript"]:Clone()
s.Disabled = false
s.Parent = p
p.Parent = game.Workspace
wait(0)
end
end


function onActivated()
if script.Parent.Enabled == true then
script.Parent.Enabled = false
if script.Parent.Ammo.Value > 0 then
fire(script.Parent.Parent["Humanoid"].TargetPoint)
else
script.Parent.Enabled = false
script.Parent.Handle.Reload:play()
m.Text = "Reloading."
for i =1,5 do
wait(0.3)
m.Text = m.Text .. "."
end
script.Parent.Ammo.Value = originalAmmo
updateAmmo()
script.Parent.Enabled = true
end
wait(0.1)
script.Parent.Enabled = true
end
end


function onEquipped()
local p = game.Players:GetChildren()
for i = 1,#p do
if p[i].Character == script.Parent.Parent then
m.Parent = p[i]
end
end
updateAmmo()
end

function onUnequipped()
m.Parent = nil
end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)
script.Parent.Unequipped:connect(onUnequipped)
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
04 Feb 2012 06:18 PM
No requests bro.
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Feb 2012 06:19 PM
Your argument is invalid
a request is for someone to make a whole script for me
I need to you to edit this one
go troll someone else
Report Abuse
mage11561 is not online. mage11561
Joined: 03 Sep 2008
Total Posts: 13217
04 Feb 2012 06:35 PM
That is a request,

argument valid.


go try to be smart somewhere else.
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
04 Feb 2012 06:36 PM
"I need you to edit this one"

"need" can be replaced with "request" therefore, it is an request.
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
04 Feb 2012 06:46 PM
"it is an request"

Have you ever been to school?
Report Abuse
mage11561 is not online. mage11561
Joined: 03 Sep 2008
Total Posts: 13217
04 Feb 2012 06:46 PM
yes we have,

and we know that this is a request.

now learn to script and go away.
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