yyyyyy09
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 10 |
|
|
| 01 Feb 2014 02:08 AM |
So the forage tool i'm using has a white bar and whenever i forage something, there is a loading bar that's supposed to go across the screen but its not going across :/ here's the code:(some of its probably messed up because of copying) wait(1)
local tool = script.Parent local frame = tool.Frame local label = frame.Label local timeBar = frame.TimeBar
local debounce = true
function getDist(a, b) return (a - b).magnitude end
function getForage(part) local parent = part.Parent
if parent ~= nil then local val = parent:findFirstChild("Forage")
if val == nil then val = part:findFirstChild("IForage") end
if val == nil then val = part:findFirstChild("CForage") end
if val == nil then return false, nil else return true, val end end end
function getLabel(part) local string = part.Name
return string end
function onMouseMove(mouse) local targ = mouse.Target
local player = tool.Parent.Parent local char = player.Character local head = char.Head
label.Text = ""
if targ ~= nil then local can, type = getForage(targ) if (can and type.Name == "Forage") or not targ.Locked then if getDist(head.Position, mouse.hit.p) < 15 then label.Text = getLabel(targ) end elseif can and type.Name == "IForage" then if getDist(head.Position, mouse.hit.p) < 15 then local real = game.Lighting.IF:findFirstChild(type.Value) if real ~= nil then label.Text = getLabel(real) end end elseif can and type.Name == "CForage" then if getDist(head.Position, mouse.hit.p) < 15 then local ot = game.Lighting.CF:findFirstChild(type.Value) if ot ~= nil then real = math.random(1, 2) if real == 1 then real = "Pizza" elseif real == 2 then real = "Lemonade" end label.Text = getLabel(real) end end end end end
function onSelected(mouse) local player = tool.Parent.Parent
frame.Parent = player.PlayerGui.ScreenGui
mouse.Move:connect(function() onMouseMove(mouse) end)
mouse.Button1Down:connect(function() local char = player.Character local head = char.Head local inven = player.Inventory:GetChildren()
local targ = mouse.Target
if targ ~= nil then local can, type = getForage(targ) if (can and type.Name == "Forage") or not targ.Locked then if getDist(head.Position, mouse.hit.p) < 15 then if debounce then if player.Inventory.One.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.One.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Two.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Two.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Three.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Three.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Four.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Four.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Five.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Five.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Six.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Six.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Seven.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Seven.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Eight.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Eight.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Nine.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Nine.Value = targ
targ.Parent = player.Inventory
elseif player.Inventory.Ten.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = targ:GetMass() / 25
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Ten.Value = targ
targ.Parent = player.Inventory end end end elseif can and type.Name == "IForage" then if getDist(head.Position, mouse.hit.p) < 15 then if debounce then local real = game.Lighting.IF:findFirstChild(type.Value) if real ~= nil then c = real:Clone() if player.Inventory.One.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.One.Value = c
c.Parent = player.Inventory elseif player.Inventory.Two.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Two.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Three.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Three.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Four.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Four.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Five.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Five.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Six.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Six.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Seven.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Seven.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Eight.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Eight.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Nine.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Nine.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Ten.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Ten.Value = c
c.Parent = player.Inventory end end end end
elseif can and type.Name == "CForage" then if getDist(head.Position, mouse.hit.p) < 15 then if debounce then local ot = game.Lighting.CF:findFirstChild(type.Value) real = math.random(1, 2) if real == 1 then real = ot.Pizza elseif real == 2 then real = ot.Lemonade end if real ~= nil then c = real:Clone() if player.Inventory.One.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.One.Value = c
c.Parent = player.Inventory elseif player.Inventory.Two.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Two.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Three.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Three.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Four.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Four.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Five.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Five.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Six.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Six.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Seven.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Seven.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Eight.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Eight.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Nine.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Nine.Value = c
c.Parent = player.Inventory
elseif player.Inventory.Ten.Value == nil then
local bp = targ:findFirstChild("BodyPosition")
if bp ~= nil then bp:remove() end
local time = c:GetMass() / 5
local spd = char.Humanoid.WalkSpeed char.Humanoid.WalkSpeed = 0
debounce = false
for t = 0, time, 0.05 do timeBar.Size = UDim2.new(t / time, 0, 1, 0) wait(0.05) end
debounce = true
char.Humanoid.WalkSpeed = spd
timeBar.Size = UDim2.new(0, 0, 1, 0)
player.Inventory.Ten.Value = c
c.Parent = player.Inventory end end end end end end end) end
function onDeselected() frame.Parent = tool
if example ~= nil then example.Parent = nil end end
tool.Selected:connect(onSelected) tool.Deselected:connect(onDeselected) |
|
|
| Report Abuse |
|