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: My custom backpack GUI script isn't working (LocalScript)

Previous Thread :: Next Thread 
Quaration is not online. Quaration
Joined: 06 Oct 2017
Total Posts: 91
29 Oct 2017 02:43 PM
local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local weaponValue = script.Parent:WaitForChild("weaponValue")
local weaponName = script.Parent:WaitForChild("weaponName")
local equipped = false

connection = script.Parent.MouseButton1Click:connect(function()
if (equipped == false) then
player.Character.Humanoid:EquipTool(script.Parent.weaponValue.Value)
weaponValue.Value = player.Character:WaitForChild(weaponName.Value)
equipped = false
else
player.Character.Humanoid:UnequipTool()
weaponValue.Value = player.Backpack:WaitForChild(weaponName.Value)
equipped = false
end
end)


umm
Report Abuse
Quaration is not online. Quaration
Joined: 06 Oct 2017
Total Posts: 91
29 Oct 2017 02:44 PM
Whoops I meant button click script.


umm
Report Abuse
Rex005X is online. Rex005X
Joined: 28 Apr 2016
Total Posts: 1245
29 Oct 2017 02:45 PM
I don't think the humanoid can equip a value. Could you tell us what you are trying to make?
Report Abuse
Quaration is not online. Quaration
Joined: 06 Oct 2017
Total Posts: 91
29 Oct 2017 02:47 PM
The problem here is the :WaitForChild not getting a value
It's for a custom backpack GUI

Here's the LocalScript:

local StarterGui = game:GetService('StarterGui')

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local player = game.Players.LocalPlayer

local weapons = player.PlayerGui:WaitForChild("Backpack")

while true do
weapons:ClearAllChildren()
local count = 0
for index, child in pairs(player.Backpack:GetChildren()) do
local weaponButton = game.Lighting.Button:Clone()
weaponButton.Parent = weapons
weaponButton.Position = UDim2.new(count, 0, 0 ,0)
local weaponValue = Instance.new("ObjectValue", weaponButton)
weaponValue.Name = "weaponValue"
weaponValue.Value = child
local weaponName = Instance.new("StringValue", weaponButton)
weaponName.Name = "weaponName"
weaponName.Value = child.Name
count = count + 0.075
end
wait(0.1)
end


umm
Report Abuse
VGamesPortal is not online. VGamesPortal
Joined: 14 May 2013
Total Posts: 279
29 Oct 2017 02:47 PM
What error you got
Report Abuse
Quaration is not online. Quaration
Joined: 06 Oct 2017
Total Posts: 91
29 Oct 2017 02:50 PM
Actually the :WaitForChild variables seem to be working. The problem is on line 11 where I change the value of the weaponValue


umm
Report Abuse
VGamesPortal is not online. VGamesPortal
Joined: 14 May 2013
Total Posts: 279
29 Oct 2017 02:54 PM
weaponValue.Changed:Connect(function()
weaponValue.Value = child
end)
Report Abuse
Quaration is not online. Quaration
Joined: 06 Oct 2017
Total Posts: 91
29 Oct 2017 02:57 PM
The reason I change the value is because when you select a gear it goes in to the player's character and I need to keep the option to select it on screen


umm
Report Abuse
Quaration is not online. Quaration
Joined: 06 Oct 2017
Total Posts: 91
29 Oct 2017 03:00 PM
Nevermind


umm
Report Abuse
Rex005X is online. Rex005X
Joined: 28 Apr 2016
Total Posts: 1245
29 Oct 2017 05:11 PM
Lighting shouldn't be used to store objects except for skyboxes or lighting effects. Try storing them somewhere in the workspace.
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