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: What did I do wrong?

Previous Thread :: Next Thread 
mooncraft16 is not online. mooncraft16
Joined: 13 Jul 2012
Total Posts: 103
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 is not online. 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
mooncraft16 is not online. mooncraft16
Joined: 13 Jul 2012
Total Posts: 103
25 Sep 2016 02:17 PM
Still is broken
Report Abuse
ericdabosZ is not online. ericdabosZ
Joined: 17 Feb 2015
Total Posts: 29
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
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
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 is not online. 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
mooncraft16 is not online. mooncraft16
Joined: 13 Jul 2012
Total Posts: 103
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 is not online. 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
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
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
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
25 Sep 2016 02:37 PM
anyone have any good gun meshes?
Report Abuse
mooncraft16 is not online. mooncraft16
Joined: 13 Jul 2012
Total Posts: 103
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 is not online. 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
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
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 is not online. 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
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
25 Sep 2016 02:52 PM
i leik shortnin built in func. c;

lel
Report Abuse
mooncraft16 is not online. mooncraft16
Joined: 13 Jul 2012
Total Posts: 103
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 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
25 Sep 2016 07:11 PM
Change it to 'Backpack'
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