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 » Scripters
Home Search
 

Re: Getting errors when I run a script

Previous Thread :: Next Thread 
ChopinCJ is not online. ChopinCJ
Joined: 24 Aug 2014
Total Posts: 45
02 Jan 2016 08:44 AM
Hello,
I've been trying to run a script, but when I do, I get the error "attempt to call a nil value".
Here is the script:
function giveScout(Brick) --connecting a function to when the scout giver is touched
local Player = Brick.Parent:findFirstChild ("Humanoid")
if Player ~= nil then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 40
local scoutBat = game.ServerStorage.Bat:Clone()
scoutBat.Parent = game.Players.LocalPlayer.Backpack
end
wait(1)
end

script.Parent.Touched:connect()


I removed comments from the script, so if you have any questions, ask me.

Thanks,
ChopinCJ
Report Abuse
LicePro is not online. LicePro
Joined: 08 Dec 2015
Total Posts: 467
02 Jan 2016 08:46 AM
It's scoutBack:Clone ().Parent
Report Abuse
MinisterWealthy is not online. MinisterWealthy
Joined: 05 May 2010
Total Posts: 2967
02 Jan 2016 09:56 AM
local scoutBat = game.ServerStorage.Bat

local debounce = false

script.Parent.Touched:connect(function()
if debounce == true then return end
debounce = true
local human = Brick.Parent:findFirstChild("Humanoid")
if human ~= nil then
local character = human.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player ~= nil then
player.Character.Humanoid.WalkSpeed = 40
scoutBat.Clone().Parent = player.Backpack
scoutBat.Clone().Parent = player.StarterGear -- if you want it to stay in the player's inventory
else
print("Player does not exist!")
debounce = false
end
print("Humanoid does not exist!")
debounce = false
end
wait(1)
debounce = false
end)

Fixed up the script a little. :P

You are welcome to use it if you want to.
Report Abuse
MinisterWealthy is not online. MinisterWealthy
Joined: 05 May 2010
Total Posts: 2967
02 Jan 2016 09:57 AM
local scoutBat = game.ServerStorage.Bat

local debounce = false

script.Parent.Touched:connect(function(Brick)
if debounce == true then return end
debounce = true
local human = Brick.Parent:FindFirstChild("Humanoid")
if human ~= nil then
local character = human.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player ~= nil then
player.Character.Humanoid.WalkSpeed = 40
scoutBat.Clone().Parent = player.Backpack
scoutBat.Clone().Parent = player.StarterGear -- if you want it to stay in the player's inventory
else
print("Player does not exist!")
debounce = false
end
print("Humanoid does not exist!")
debounce = false
end
wait(1)
debounce = false
end)

Forgot to add "Brick" into the parameters, use this one instead.
Report Abuse
ChopinCJ is not online. ChopinCJ
Joined: 24 Aug 2014
Total Posts: 45
02 Jan 2016 10:43 AM
Thanks for the help!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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