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: Is there a problem here?

Previous Thread :: Next Thread 
FancyPig19 is not online. FancyPig19
Joined: 23 Sep 2014
Total Posts: 269
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
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