NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 29 Apr 2014 07:22 PM |
| Because you are changing the tool in starterpack. |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 29 Apr 2014 07:25 PM |
| You are changing the tool in starterpack... Not in backpack. |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 29 Apr 2014 07:28 PM |
| Yeah, but if the tool is equipped, it's parent is the character. |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 29 Apr 2014 07:32 PM |
if plr.Character:FindFirstChild("Tool") then f=plr.Character['Tool'] elseif plr.Backpack:findFirstChild("Tool") then f=plr.Backpack['Tool'] |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 29 Apr 2014 07:34 PM |
| Whatever flashlight is, I thought it was f sorry. |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 29 Apr 2014 07:39 PM |
function die() --here
tell me if it works |
|
|
| Report Abuse |
|
|
Exus100
|
  |
| Joined: 11 Aug 2007 |
| Total Posts: 351 |
|
|
| 29 Apr 2014 07:40 PM |
First off
stat = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Players.LocalPlayer.leaderstats.Gold ^ Ew
plr = game.Players.LocalPlayer stat = plr.leaderstats.Gold stat2 = plr.leaderstats.Rubies
function die() if stat.Value>=10 then
f = plr.Backpack.Flashlight.LightPart.Light f.Range = f.Range + 7 f.Brightness = f.Brightness + 12 stat.Value = stat.Value - 10
elseif stat2.Value>=5 then
f.Brightness = f.Brightness + 12 f.Range = f.Range + 7 stat2.Value = stat2.Value - 10
else
script.Parent.Text = ("You don't have enough currency!") wait(5) script.Parent.Text = ("Upgrade Flashlight")
end end
script.Parent.MouseButton1Down:connect(die)
Second off: And there is a lot to be done there, like disconnecting when giving error message, editng flashlight when equipped (in players hand / character model), appropriat function names? (die? really?)
|
|
|
| Report Abuse |
|
|
Exus100
|
  |
| Joined: 11 Aug 2007 |
| Total Posts: 351 |
|
|
| 29 Apr 2014 07:47 PM |
wait. still not done, my bad.
plr = game.Players.LocalPlayer stat = plr.leaderstats.Gold stat2 = plr.leaderstats.Rubies
function UpgradeFlashlight() local flashlight = plr.Backpack:FindFirstChild("Flashlight") or plr.Character:FindFirstChild("Flashlight") --Check if in backpack or equipped
if (flashlight ~= nil) then --If flashlight exists local light = flashlight.LightPart.Light --Declare before if statements, not in one if you're using it in multiple if statements
if (stat.Value >= 10) then
light.Range = light.Range + 7 light.Brightness = light.Brightness + 12 stat.Value = stat.Value - 10
elseif (stat2.Value >= 5) then
light.Brightness = light.Brightness + 12 light.Range = light.Range + 7 stat2.Value = stat2.Value - 5 --I think you meant 5, not 10
else
script.Parent.Text = ("You don't have enough currency!") wait(5) script.Parent.Text = ("Upgrade Flashlight")
end end end
script.Parent.MouseButton1Down:connect(UpgradeFlashlight) |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
Exus100
|
  |
| Joined: 11 Aug 2007 |
| Total Posts: 351 |
|
|
| 29 Apr 2014 07:49 PM |
Sorry for spam > final revision
plr = game.Players.LocalPlayer stat = plr.leaderstats.Gold stat2 = plr.leaderstats.Rubies
function UpgradeFlashlight() local flashlight = plr.Backpack:FindFirstChild("Flashlight") or plr.Character:FindFirstChild("Flashlight") --Check if in backpack or equipped
if (flashlight ~= nil) then --If flashlight exists local light = flashlight.LightPart.Light --Declare before if statements, not in one if you're using it in multiple if statements
if (stat.Value >= 10) then
light.Range = light.Range + 7 light.Brightness = light.Brightness + 12 stat.Value = stat.Value - 10
elseif (stat2.Value >= 5) then
light.Brightness = light.Brightness + 12 light.Range = light.Range + 7 stat2.Value = stat2.Value - 5 --I think you meant 5, not 10
else connection:disconnect(); script.Parent.Text = ("You don't have enough currency!") wait(5) script.Parent.Text = ("Upgrade Flashlight") connection = script.Parent.MouseButton1Down:connect(UpgradeFlashlight) end end end
connection = script.Parent.MouseButton1Down:connect(UpgradeFlashlight) |
|
|
| Report Abuse |
|
|
Exus100
|
  |
| Joined: 11 Aug 2007 |
| Total Posts: 351 |
|
|
| 29 Apr 2014 07:50 PM |
| well sorry for trying to teach you a thing and two and you're welcome for fixing it. |
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
Exus100
|
  |
| Joined: 11 Aug 2007 |
| Total Posts: 351 |
|
|
| 29 Apr 2014 08:07 PM |
script.Parent.Text = "You don't have enough currency!" wait(5) script.Parent.Text = "Upgrade Flashlight"
didnt see that one
|
|
|
| Report Abuse |
|
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|
NeonRiver
|
  |
| Joined: 12 Feb 2013 |
| Total Posts: 4936 |
|
| |
|