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
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
|
| 02 Jan 2016 08:46 AM |
| It's scoutBack:Clone ().Parent |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 24 Aug 2014 |
| Total Posts: 45 |
|
| |
|