|
| 02 Dec 2016 01:01 PM |
I just typed up and tried this script:
local tool = script.Parent local player = game.Players.LocalPlayer local scripts = player:WaitForChild("PlayerScripts") local max = scripts:WaitForChild("InventoryMax")
while wait (0.1) do previous1 = player.Character:FindFirstChild("School Backpack (Accessory)") if previous1 == nil then if tool.Parent == player.Backpack then max.Value = 10 print ("10 Inventory") local pack = game.ServerStorage:FindFirstChild("School Backpack (Accessory)") local clone = pack:Clone() clone.Parent = player.Character local attachment = pack.Handle.BackAttachment local aclone = attachment:Clone() aclone.Parent = player.Character.Torso function onEquipped(Mouse) clone = game.Debris aclone = game.Debris max.Value = 6 print("6 Inventory") end end else wait(0.5) end end
tool.Equipped:connect(onEquipped)
The main part of the script works fine, but the last function doesn't work at all. If someone could help me, that would be great. Thanks! |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 02 Dec 2016 01:50 PM |
| What are you trying to do with the equipped function? |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 02 Dec 2016 01:58 PM |
--Perhaps this is what you wanted?
tool, p, pack = script.Parent, game.Players.LocalPlayer, game.ServerStorage:WaitForChild'School Backpack (Accessory)' s = p:WaitForChild'PlayerScripts' max = s:WaitForChild'InventoryMax' repeat wait() until p.Character c = p.Character t = c:WaitForChild'Torso'
c.ChildAdded:connect(function() local prev = c:FindFirstChild'School Backpack (Accessory)' if not prev then if tool.Parent == p.Backpack then max.Value = 10 local np = pack:Clone() np.Parent = c local attachment = np.Handle.BackAttachment local aclone = attachment:Clone() aclone.Parent = t aclone.Name = prev.Name end end end)
tool.Equipped:connect(function() local prev = c:FindFirstChild'School Backpack (Accessory)' if prev then prev:Destroy() local attach = t:FindFirstChild(prev.Name) if attach then attach:Destroy() end end max.Value = 6 end) |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 02 Dec 2016 02:01 PM |
--Update for the character checking script.
c.ChildAdded:connect(function() local prev = c:FindFirstChild'School Backpack (Accessory)' if not prev and tool.Parent == p.Backpack then max.Value = 10 local np = pack:Clone() np.Parent = c local attachment = np.Handle.BackAttachment local aclone = attachment:Clone() aclone.Parent = t aclone.Name = prev.Name end end)
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 02 Dec 2016 02:04 PM |
--Better yet cut out the repeating name.
tool, p, pack = script.Parent, game.Players.LocalPlayer, game.ServerStorage:WaitForChild'School Backpack (Accessory)' s = p:WaitForChild'PlayerScripts' max = s:WaitForChild'InventoryMax' repeat wait() until p.Character c = p.Character t = c:WaitForChild'Torso'
c.ChildAdded:connect(function() local prev = c:FindFirstChild(pack.Name) if not prev and tool.Parent == p.Backpack then max.Value = 10 local np = pack:Clone() np.Parent = c local attachment = np.Handle.BackAttachment local aclone = attachment:Clone() aclone.Parent = t aclone.Name = prev.Name end end)
tool.Equipped:connect(function() local prev, attach = c:FindFirstChild(pack.Name), t:FindFirstChild(pack.Name) if prev then prev:Destroy() if attach then attach:Destroy() end end max.Value = 6 end) |
|
|
| Report Abuse |
|
|