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
|
  |
| Joined: 06 Oct 2017 |
| Total Posts: 91 |
|
|
| 29 Oct 2017 02:44 PM |
Whoops I meant button click script.
umm |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
|
| 29 Oct 2017 02:54 PM |
weaponValue.Changed:Connect(function() weaponValue.Value = child end) |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 06 Oct 2017 |
| Total Posts: 91 |
|
| |
|
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 |
|
|