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: Shotgun script not working?

Previous Thread :: Next Thread 
GRAGGER2001 is not online. GRAGGER2001
Joined: 05 Apr 2009
Total Posts: 2043
13 Jan 2014 09:23 PM
--attempt to call a nil value
--22:22:32.541 - Disconnected event because of exception
Thats the only error I get.


hunter=[[GRAGGER2001]]
game:GetService('Players'):WaitForChild(hunter)
print('Waiting for '..hunter)
plr=game:GetService('Players')[hunter]
gui=plr.PlayerGui
mouse=plr:GetMouse()
tools=plr.Backpack
local shotgun = Instance.new('Tool',tools)
shotgun.Name='shotgun'
local part=Instance.new('Part',shotgun)
part.Name='Handle'
part.Size=Vector3.new(1,1,5)
part.BrickColor=BrickColor.new('Dark stone grey')
local mesh = Instance.new('SpecialMesh',part)
mesh.MeshId='http://www.roblox.com/asset/?id=94219391'
mesh.TextureId='http://www.roblox.com/asset/?id=94219470'
local screengui = Instance.new('ScreenGui')
screengui.Name='Shotgun Gui'
local frame = Instance.new('Frame',screengui)
frame.Position=UDim2.new(0, 600, 0, 350)
frame.Size=UDim2.new(0, 100, 0, 50)
frame.BackgroundTransparency=1
frame.Name='Shotgun Frame'
local txt = Instance.new('TextLabel',frame)
txt.Name='Birdshot/Slugs/Dragonfire'
txt.BackgroundTransparency=1
txt.TextColor3=BrickColor.new('Really red').Color
txt.Text='Birdshot'
birdshot=true
slugs=false
dragonfire=false
shotgun.Equipped:connect(function(equiped)
local shotteller = screengui:Clone()
shotteller.Parent=gui
local mytxt=shotteller:FindFirstChild('Shotgun Frame'):FindFirstChild('Birdshot/Slugs/Dragonfire')
mouse.Button1Down:connect(function(clicked)
if birdshot==true then
local bullet = Instance.new('Part',game.Workspace)
bullet.Name='Bullet'
bullet.FormFactor='Custom'
bullet.Size=Vector3.new(.2, .2, .2)
bullet.Shape='Ball'
bullet.BrickColor=BrickColor.new('Really black')
local spd = Instance.new('BodyForce',bullet)
spd.force=Vector3.new(0, 100, 900)
wait(.5)
bullet2=bullet:Clone()
bullet2.Parent=game.Workspace
wait(.5)
bullet3=bullet:Clone()
bullet3.Parent=game.Workspace
wait(.5)
bullet4=bullet:Clone()
bullet4.Parent=game.Workspace
wait(.5)
bullet5=bullet:Clone()
bullet5.Parent=game.Workspace
function touched (ontouch)
if ontouch.Parent:FindFirstChild('Humanoid')then
ontouch.Parent:FindFirstChild('Humanoid').Health=ontouch.Parent:FindFirstChild('Humanoid')-50
end
end
function touched (ontouch2)
if ontouch2.Parent:FindFirstChild('Humanoid')then
ontouch2.Parent:FindFirstChild('Humanoid').Health=ontouch2.Parent:FindFirstChild('Humanoid')-50
end
end
function touched (ontouch3)
if ontouch3.Parent:FindFirstChild('Humanoid')then
ontouch3.Parent:FindFirstChild('Humanoid').Health=ontouch3.Parent:FindFirstChild('Humanoid')-50
end
end
function touched (ontouch4)
if ontouch4.Parent:FindFirstChild('Humanoid')then
ontouch4.Parent:FindFirstChild('Humanoid').Health=ontouch4.Parent:FindFirstChild('Humanoid')-50
end
end
function touched (ontouch5)
if ontouch5.Parent:FindFirstChild('Humanoid')then
ontouch5.Parent:FindFirstChild('Humanoid').Health=ontouch5.Parent:FindFirstChild('Humanoid')-50
end
end
bullet.Touched:connect(touched)
bullet2.Touched:connect(touched2)
bullet3.Touched:connect(touched3)
bullet4.Touched:connect(touched4)
bullet5.Touched:connect(touched5)
elseif dragonfire==true then
local bullet = Instance.new('Part',game.Workspace)
bullet.Name='Bullet'
bullet.FormFactor='Custom'
bullet.Size=Vector3.new(.2, .2, .2)
bullet.Shape='Ball'
bullet.CFrame=CFrame.new(plr.Character.Head.Position)
bullet.Rotation=Vector3.new(plr.Character.Head.Rotation)
bullet.BrickColor=BrickColor.new('Really black')
local spd = Instance.new('BodyForce',bullet)
spd.force=Vector3.new(0, 100, 900)
wait(.5)
bullet2=bullet:Clone()
bullet2.Parent=game.Workspace
wait(.5)
bullet3=bullet:Clone()
bullet3.Parent=game.Workspace
wait(.5)
bullet4=bullet:Clone()
bullet4.Parent=game.Workspace
wait(.5)
bullet5=bullet:Clone()
bullet5.Parent=game.Workspace
elseif slugs==true then
local bullet = Instance.new('Part',game.Workspace)
bullet.Name='Bullet'
bullet.FormFactor='Custom'
bullet.Size=Vector3.new(.2, .2, .2)
bullet.BrickColor=BrickColor.new('Really black')
bullet.Shape='Ball'
local spd = Instance.new('BodyForce',bullet)
spd.force=Vector3.new(0, 50, 900)
end
end)
mouse.KeyDown:connect(function(key)
if key=='z'then
if birdshot~=true then
birdshot=true
slugs=false
dragonfire=false
mytxt.Text='Birdshot'
end
elseif key=='x'then
if slugs~=true then
birdshot=false
slugs=true
dragonfire=false
mytxt.Text='Buck shot'
end
elseif key=='c'then
if dragonfire~=true then
birdshot=false
slugs=false
dragonfire=true
mytxt.Text='Dragonfire'
end
end
end)
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
13 Jan 2014 09:26 PM
Read the script super carefully.
Report Abuse
GRAGGER2001 is not online. GRAGGER2001
Joined: 05 Apr 2009
Total Posts: 2043
13 Jan 2014 09:26 PM
I already have. 10 times to be exact.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
13 Jan 2014 09:30 PM
If you can't find your logical error, make a separate script for all the functions, test them, and see which errors then find it from there.



Or redo your entire script. This error truly sucks.
Report Abuse
yankeejr is not online. yankeejr
Joined: 04 Jul 2012
Total Posts: 4906
13 Jan 2014 09:30 PM
'key'? It's supposed to be "key"... Ex: key="c"
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 Jan 2014 09:31 PM
No, it doesn't matter.
Report Abuse
GRAGGER2001 is not online. GRAGGER2001
Joined: 05 Apr 2009
Total Posts: 2043
13 Jan 2014 09:31 PM
'' works the same as ""
Report Abuse
GRAGGER2001 is not online. GRAGGER2001
Joined: 05 Apr 2009
Total Posts: 2043
13 Jan 2014 09:44 PM
Can anyone help me fix it?
Report Abuse
GRAGGER2001 is not online. GRAGGER2001
Joined: 05 Apr 2009
Total Posts: 2043
13 Jan 2014 10:42 PM
b1
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