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: Why does this shoot from the baseplate?

Previous Thread :: Next Thread 
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:23 PM
It starts shooting from the baseplate when it's suppose to come from the gun/snowball..

local Ammo = 25
local BulletDamage = 5
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Gun = game.StarterPack.Snowball


function Damage(Part)
if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= Player.Name then
Part.Parent.Humanoid:TakeDamage(BulletDamage)
Bullet:Destroy()
end
end

function shoot()
if Ammo <= 25 then
wait()
Bullet = Instance.new("Part", workspace)
Bullet.Touched:connect(Damage)
Bullet.Shape = "Ball"
Bullet.Size = Vector3.new(0.1, 0.1, 0.1)
Bullet.TopSurface = "Smooth"
Bullet.BottomSurface = "Smooth"
Bullet.BrickColor = BrickColor.new("Bright red")
Bullet.CanCollide = true
Bullet.CFrame = Gun.Handle.CFrame
Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
v = Instance.new("BodyVelocity", Bullet)
v.velocity = Bullet.CFrame.lookVector *90
v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
game.Debris:AddItem(Bullet, 1)

end
end
script.Parent.Parent.Activated:connect(shoot)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
15 Dec 2013 04:26 PM
replace
"Bullet.CFrame = Gun.Handle.CFrame
Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)"

with
"Bullet.CFrame = CFrame.new(Gun.Handle.Position, mouse.Hit.P)"

And replace
"v = Instance.new("BodyVelocity", Bullet)
v.velocity = Bullet.CFrame.lookVector *90
v.maxForce = Vector3.new(math.huge, math.huge, math.huge)"

with
"Bullet.Velocity = mouse.Hit.p.unit * 90
v = Instance.new("BodyForce", Bullet)
v.Force = Vector3.new(0, Bullet:GetMass() * 196.2, 0)"
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:30 PM
What's getmass()?
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:32 PM
@Cnt, they don't disappear now, they, they don't shoot from my gun...
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:34 PM
Ouput is : 17:34:18.288 - Force is not a valid member of BodyForce
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
15 Dec 2013 04:35 PM
(Gun.Handle.Position + (Gun.Handle.CFrame.lookVector*5))
For the position part of CF
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
15 Dec 2013 04:35 PM
oops, try .force, so v.force = ...
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:43 PM
This is what I have so far and it still starts shooting from the base...:



local Ammo = 25
local BulletDamage = 5
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Gun = game.StarterPack.Snowball


function Damage(Part)
if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= Player.Name then
Part.Parent.Humanoid:TakeDamage(BulletDamage)
Bullet:Destroy()
end
end

function shoot()
if Ammo <= 25 then
wait()
Bullet = Instance.new("Part", workspace)
Bullet.Touched:connect(Damage)
Bullet.Shape = "Ball"
Bullet.Size = Vector3.new(0.1, 0.1, 0.1)
Bullet.TopSurface = "Smooth"
Bullet.BottomSurface = "Smooth"
Bullet.BrickColor = BrickColor.new("Bright red")
Bullet.CanCollide = true
Bullet.CFrame = CFrame.new(Gun.Handle.Position + (Gun.Handle.CFrame.lookVector*5))
Bullet.Velocity = mouse.Hit.p.unit * 90
v = Instance.new("BodyForce", Bullet)
v.force = Vector3.new(0, Bullet:GetMass() * 196.2, 0)
game.Debris:AddItem(Bullet, 1)

end
end
script.Parent.Parent.Activated:connect(shoot)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
15 Dec 2013 04:46 PM
It's in a localscript and right?
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:49 PM
Yes, it's in a localscript...
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
15 Dec 2013 04:51 PM
This is your problem:
"local Gun = game.StarterPack.Snowball"
You probably wanted
"local Gun = script.Parent"
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 04:57 PM
Ok, comes from me now, but doesn't go to where my mouse goes.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
15 Dec 2013 05:10 PM
What do you currently have?
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
15 Dec 2013 05:37 PM
local Ammo = 25
local BulletDamage = 5
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Gun = script.Parent.Parent

function Damage(Part)
if Part.Parent:FindFirstChild("Humanoid") and Part.Parent.Name ~= Player.Name then
Part.Parent.Humanoid:TakeDamage(BulletDamage)
Bullet:Destroy()
end
end

function shoot()
if Ammo <= 25 then
wait()
Bullet = Instance.new("Part", workspace)
Bullet.Touched:connect(Damage)
Bullet.Shape = "Ball"
Bullet.Size = Vector3.new(0.1, 0.1, 0.1)
Bullet.TopSurface = "Smooth"
Bullet.BottomSurface = "Smooth"
Bullet.BrickColor = BrickColor.new("Bright red")
Bullet.CanCollide = true
Bullet.CFrame = CFrame.new(Gun.Handle.Position + (Gun.Handle.CFrame.lookVector*5))
Bullet.Velocity = mouse.Hit.p.unit * 90
v = Instance.new("BodyForce", Bullet)
v.force = Vector3.new(0, Bullet:GetMass() * 196.2, 0)
game.Debris:AddItem(Bullet, 1)

end
end
script.Parent.Parent.Activated:connect(shoot)
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