|
| 25 Sep 2016 02:06 PM |
I am trying to make it where when I step on a part and press e a gun pops into my inventory however it's not working, anyone know why?
local MyMouse = game.Players.LocalPlayer:GetMouse()
function OnTouch()
MyMouse.KeyDown:connect(function(key)
if string.lower(key) == "e" then local gun = game.Lighting.Glock:Clone() gun.Parent = game.Players:FindFirstChild(key.Parent.Name).StarterGear
end end) end script.Parent.Touched:connect(OnTouch) |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 25 Sep 2016 02:08 PM |
game:GetService('UserInputService').InputBegan:connect(function(iO,gPE) if not gPE then if iO.KeyCode==Enum.KeyCode.E then --script end end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Sep 2016 02:21 PM |
| error message: 15:21:18.929 - Workspace.Weapon Save Script:37: attempt to index field 'Character' (a nil value) |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:27 PM |
1.KeyDown is deprrecated 2.Use UserInputService or ContextActionService to replace KeyDown
local player = game.Players.LocalPlayer local Uis = game:GetService("UserInputService")
Uis.InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.E then --do stuff end end |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 25 Sep 2016 02:30 PM |
well the script you posted is obviously correct if it's doing everything you want does the gun work without this? are the scripts in the gun disabled? are you sure everything is copied correctly? use an explorer to double check |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:33 PM |
Yeah everything is working without this script if I place the gun inside of Starterpack I still have an error with the 8th line of code
gun.Parent = game.Players:FindFirstChild(player).StarterGear
here is all the code
local player = game.Players.LocalPlayer local Uis = game:GetService("UserInputService")
Uis.InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.E then local gun = game.Lighting.Glock:Clone() gun.Parent = game.Players:FindFirstChild(player).StarterGear
end end) |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 25 Sep 2016 02:34 PM |
oh, gun.Parent=player since you already defined it |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:35 PM |
you need to put it in the backpack too
local player = game.Players.LocalPlayer local wfc = WaitForChild local backpack = player:wfc("BackPack") |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:37 PM |
| anyone have any good gun meshes? |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:44 PM |
still giving me an error
local player = game.Players.LocalPlayer local Uis = game:GetService("UserInputService") local wfc = WaitForChild local backpack = player:wfc("BackPack")
Uis.InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.E then local gun = game.Lighting.Glock:Clone() gun.Parent = backpack
end end) |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 25 Sep 2016 02:48 PM |
why did you change it ugh
local wfc=player.WaitForChild local backpack=wfc(player,'Backpack')
why would you even go about that
local backpack=player:WaitForChild'Backpack' pls |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:51 PM |
try ContentActionService and i guess you must put it into StarterGear and the backpack too
local player = game.Players.LocalPlayer
function onKeyPress(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin then local gun = game.Lighting.Glock:clone() gun.Parent = player:WaitForChild("BackPack") gun.Parent = StarterGear end end game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E) |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 25 Sep 2016 02:52 PM |
please be trolling
local player = game.Players.LocalPlayer local Uis = game:GetService("UserInputService")
Uis.InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.E then local gun = game.Lighting.Glock:Clone() gun.Parent = player:WaitForChild("BackPack")
end end) |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 02:52 PM |
i leik shortnin built in func. c;
lel |
|
|
| Report Abuse |
|
|
|
| 25 Sep 2016 03:12 PM |
warning message:
16:10:33.789 - Infinite yield possible on 'Players.Player1:WaitForChild("BackPack")'
still not working
local player = game.Players.LocalPlayer local Uis = game:GetService("UserInputService")
Uis.InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.E then local gun = game.Lighting.Glock:Clone() gun.Parent = player:WaitForChild("BackPack")
end end)
|
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
| |
|