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: attempt to call nil value

Previous Thread :: Next Thread 
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 04:04 PM
attempt to call nil value.

That's all output said. Now, I understand this can be a pain to read, so I recommend viewing the script here:
pastebin DOT com/SEbDXNF5




local w_damage = 1777
local w_mdamage = 5000
local fire_rate = 0.2
local spread = .08
local ToolMouseIcon = "http://www.roblox.com/asset/?id=57571495"
local hole_stay = 5
local blood = true
local blooddrop_stay = 2
local blooddrops = 5
local debug = true
--///////////////////////////////
local Tool = script.Parent
local User
local firing = false
local equipped = false
local _vals = script.Parent.Values
--///////////////////////////////

function _print(tx)
if debug then
print(tx)
end
end

wait(0.2)



function Fire(mouse)
_print("Fire(mouse)")
firing = true
while firing do wait()
_print("Fire loop")
if firing then
if _vals.Clip.Value <= 0 then
return
end
Tool.Handle.Fire:Play()
_vals.Clip.Value = _vals.Clip.Value - 1
_print("direction:")
local dir = (mouse.Hit.p - Tool.Handle.CFrame.p).unit
_print(tostring(dir))
dir = dir + Vector3.new(math.random(-spread,spread)/500,math.random(-spread,spread)/500,math.random(-spread,spread)/500)
local Ray = Ray.new(Tool.Handle.CFrame.p,(dir).unit*999)
local Hit,Position = game.Workspace:FindPartOnRayWithIgnoreList(Ray,{User,game.Workspace.Debug})
if Hit then
_print("Target detected. Bullet is on its way.")
wait((Position - Tool.Handle.Position).magnitude / 1000 * 1.5)
_print("The bullet has hit the target!")
function drawhole()
local hole = Instance.new("Part", game.Workspace.Debug)
hole.CFrame = CFrame.new(Position,Position + Ray.Direction)
hole.Locked = true
hole.Name = "BulletHole"
hole.Anchored = true
hole.CanCollide = false
hole.BrickColor = BrickColor.new("Really black")
hole.FormFactor = "Custom"
hole.Size = Vector3.new(.2,.2,.2)
local hole_m = Instance.new("SpecialMesh")
hole_m.Scale = Vector3.new(1.1,1.1,1.1)
hole_m.MeshType = "Sphere"
hole_m.Parent = hole
coroutine.resume(coroutine.create(function (item)
wait(hole_stay)
hole:Destroy() end), hole)
end
if Hit.Anchored then
drawhole()
else --if not anchored
local f = Instance.new("BodyForce", Hit)
f.force = Hit.CFrame.lookVector * 2000
coroutine.resume(coroutine.create(function (item)
wait(1)
f:Destroy() end), f)
end
if Hit.Name=="BulletHole" then
Hit:Destroy()
end
if Hit.Parent:FindFirstChild("Humanoid") then
if blood then
for i = 1, blooddrops do
local p = Instance.new("Part", workspace.Debug)
p.CanCollide = false
p.Transparency = 0.3
p.BrickColor = BrickColor.new("Bright red")
p.Size = Vector3.new(1,1,1)
p.Position = Hit.Position + Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1))
p.Velocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
local b_m = Instance.new("SpecialMesh")
b_m.Scale = Vector3.new(1,1.5,1)
b_m.MeshType = "Sphere"
b_m.Parent = p
coroutine.resume(coroutine.create(function (item)
wait(blooddrop_stay)
p:Destroy() end), p)
end
end
if Hit.Name == "Head" or Hit.Name == "FakeHead" then
Hit.Parent.Humanoid:TakeDamage(w_mdamage)
else
Hit.Parent.Humanoid:TakeDamage(w_damage)
end
end
end
end
wait(fire_rate)
end
end




function onButton1Up(mouse)
firing = false
end

function keyPressed(key)
key:lower()
if key == "q" then
--
end
end

function Equip(mouse)
end

function unEquip()
equipped = false
end

function onEquippedLocal(mouse)
equipped = true
--game.Workspace.CurrentCamera.CameraMode = 1
if mouse == nil then
print("Mouse not found")
return
end
mouse.Icon = ToolMouseIcon
Tool.Parent.Humanoid.Running:connect(Run)
mouse.Button1Down:connect(function() Fire(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
mouse.KeyDown:connect(keyPressed)
Tool.Unequipped:connect(unEquip)
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Equipped:connect(Equip)
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 04:05 PM
It prints _print(tostring(dir))
and stops after that.
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
01 Sep 2012 04:05 PM
This is why you are supposed to use print()

~xXTheRobotXx, Cyborg of OT~
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
01 Sep 2012 04:06 PM
If you can make all of that, you'll know where to work at..

(>•д•)> ¤ ¤ † KMXD 2.0 † ¤ ¤ [SHG Tier~ nil] (^•д•^) [KMXD Stole this sig] <(•д•<)
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 04:33 PM
@xXTheRobotXx Please notice my first reply. I use prints. READ GODDARNIT


@XxChopSlaperxX
I need help on this odd error. I think it has something to do with the connections
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 04:51 PM
Come on, I made it easier for you. I even used prints.
If you see my first reply, I told what it prints lastly.
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 06:40 PM
bump...
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 07:30 PM
seriously no-one?
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Sep 2012 07:56 PM
Come on
Report Abuse
Aerideyn is not online. Aerideyn
Joined: 16 Jan 2010
Total Posts: 1882
01 Sep 2012 08:07 PM
Attempt to call nil value often means you tried to call a function which doesnt exist, check the capitalisation of your calls.

Add more prints, isolate the exact line where the nil call is made and then find out where it has gone if it is supposed to be there.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
01 Sep 2012 08:13 PM
What they said... and wow. Big script o.e
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