|
| 08 Feb 2013 07:55 PM |
As you can well imagine, im a beginner scripter. But i can script SOME things. Anyways. I am making a mining game, i tried to script a pickaxe, but it failed. I know theres thousands of errors. I dunno.
function onMouse(click) click = MouseClick
if click.Parent.Name = "Dirt" then leaderstats.Cash = +1
if click.Parent.Name = "Copper" then leaderstats.Cash = +3
if click.Parent.Name = "Bronze" then leaderstats.Cash = +8
if click.Parent.Name = "Silver" then leaderstats.Cash = +20
if click.Parent.Name = "Gold" then leaderstats.Cash = +50
if click.Parent.Name = "Ruby" then leaderstats.Cash = +100
if click.Parent.Name = "Diamond" then leaderstats.Cash = +250
onMouseClick:connect(remove) end
It's in a tool's handle. I dunno what to add, the output don't make no sense. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 07:56 PM |
You never ended them. However it'd be easier to use 'elseif' And use two equal signs when checking if something equals something.
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 07:57 PM |
| Ok. I knew i forgot something. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 07:58 PM |
| Can ya change it for me? I don't really know what to do with it. |
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 08 Feb 2013 07:58 PM |
function onMouse(click)
if click.Parent.Name == "Dirt" then leaderstats.Cash = leaderstats.Cash+1
elseif click.Parent.Name == "Copper" then leaderstats.Cash = leaderstats.Cash+3
elseif click.Parent.Name == "Bronze" then leaderstats.Cash = leaderstats.Cash+8
elseif click.Parent.Name == "Silver" then leaderstats.Cash = leaderstats.Cash+20
elseif click.Parent.Name == "Gold" then leaderstats.Cash = leaderstats.Cash+50
elseif click.Parent.Name == "Ruby" then leaderstats.Cash = leaderstats.Cash+100
elseif click.Parent.Name == "Diamond" then leaderstats.Cash = leaderstats.Cash+250 end
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(onMouse) end)
try this |
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 08 Feb 2013 08:00 PM |
Sorry for double post, but if it's in the tool's handle then it should be:
function onMouse(click)
if click.Parent.Name == "Dirt" then leaderstats.Cash = leaderstats.Cash+1
elseif click.Parent.Name == "Copper" then leaderstats.Cash = leaderstats.Cash+3
elseif click.Parent.Name == "Bronze" then leaderstats.Cash = leaderstats.Cash+8
elseif click.Parent.Name == "Silver" then leaderstats.Cash = leaderstats.Cash+20
elseif click.Parent.Name == "Gold" then leaderstats.Cash = leaderstats.Cash+50
elseif click.Parent.Name == "Ruby" then leaderstats.Cash = leaderstats.Cash+100
elseif click.Parent.Name == "Diamond" then leaderstats.Cash = leaderstats.Cash+250 end
script.Parent.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(onMouse) end)
otherwise use the previous post code. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 08:01 PM |
| Does it remove the brick when its clicked, and can you add in a wait() before you can use it again? Otherwise people will spam the mine. |
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 08 Feb 2013 08:02 PM |
Sorry for another post xD
function onMouse(click) c=game.Players:playerFromCharacter(script.Parent.Parent.Parent.Name).leaderstats.Cash.Value
if click.Parent.Name == "Dirt" then c = c +1
elseif click.Parent.Name == "Copper" then c = c +3
elseif click.Parent.Name == "Bronze" then c = c +8
elseif click.Parent.Name == "Silver" then c = c +20
elseif click.Parent.Name == "Gold" then c = c +50
elseif click.Parent.Name == "Ruby" then c = c +100
elseif click.Parent.Name == "Diamond" then c = c +250 end
script.Parent.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(onMouse) end)
|
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 08:04 PM |
It's GetPlayerFromCharacter
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
| |
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 08 Feb 2013 08:06 PM |
Cody, I don't think it matters...
King, I will make you a new script, give me 2 mins. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 08 Feb 2013 08:07 PM |
| ashispro, what a familiar name I am seeing..... |
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 08 Feb 2013 08:10 PM |
| Hey MrNic, long time no speak! |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2013 08:11 PM |
It matters.
~~Advanced Scripter |
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 08 Feb 2013 08:27 PM |
Names = {"Dirt","Copper","Bronze","Silver","Gold","Ruby","Diamond"} -- the names of the blocks Cash = {1,3,8,20,50,100,250} -- how much cash you get for the above TimeToWait = 2 -- seconds before using again Distance = 10 -- distance they can use the tool from deb = false
function onMouse(mouse) if mouse.Target ~= nil then hit = mouse.Target if deb == false then local c = game.Players[script.Parent.Parent.Parent.Name].leaderstats.Cash deb = true for i = 1,#Names do if hit.Name == Names[i] and (hit.Position - script.Parent.Parent.Parent.Torso.Position).magnitude < Distance + 1 then c.Value = c.Value + Cash[i] hit:remove() end end wait(TimeToWait) deb = false end end end
script.Parent.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() onMouse(mouse) end) end) |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2013 12:52 PM |
| Thank you, i think we got a winner. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2013 12:58 PM |
Sorry about this but, i added a health value inside each block, they each take a different amount of hits before there removed. I tried to script the pickaxe to do that event aswell, but it won't work. I also added a Damage value inside the pickaxe, not in the handle. Can you or someone else fix this? I can post it, if you'd like.
-Intermediate Scripter |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2013 01:02 PM |
| Actually, nevermind. It doesn't even work. I tried it both ways. ): |
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 09 Feb 2013 05:49 PM |
Reading what you put, I couldn't tell if you wanted blocks to have health/if the pickaxe should have health. So I added both, add this into the script of the handle again. I'm assuming you have some knowledge on how to edit tables, and values e.t.c
Names = {"Dirt","Copper","Bronze","Silver","Gold","Ruby","Diamond"} -- the names of the blocks Cash = {1,3,8,20,50,100,250} -- how much cash you get for the above Hits = {1,2,3,4,5,6,7} --how many hits for each one TimeToWait = 1.5 -- seconds before using again Distance = 10 -- distance they can use the tool from Damage = 100 --amount of hits before it breaks deb = false
function onMouse(mouse) if mouse.Target ~= nil then hit = mouse.Target if deb == false and 0 < Damage then local c = game.Players[script.Parent.Parent.Parent.Name].leaderstats.Cash deb = true for i = 1,#Names do if hit.Name == Names[i] and (hit.Position - script.Parent.Parent.Parent.Torso.Position).magnitude < Distance + 1 then Damage = Damage - 1 if hit:findFirstChild"Amount" then if hit.Amount.Value == Hits[i] then c.Value = c.Value + Cash[i] hit:remove() elseif hit.Amount.Value < Hits[i] then hit.Amount.Value = hit.Amount.Value + 1 end elseif not hit:findFirstChild"Amount" then local h = Instance.new"IntValue" h.Parent = hit h.Name = "Amount" h.Value = 1 end end end wait(TimeToWait) deb = false end end end
script.Parent.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() onMouse(mouse) end) end)
|
|
|
| Report Abuse |
|
|
ashispro
|
  |
| Joined: 14 Sep 2008 |
| Total Posts: 452 |
|
|
| 09 Feb 2013 06:18 PM |
Final fix you wrote to me in chat:
Names = {"Dirt","Copper","Bronze","Silver","Gold","Ruby","Diamond"} -- the names of the blocks Cash = {1,3,8,20,50,100,250} -- how much cash you get for the above Hits = {1,2,3,4,5,6,7} --how many hits for each one TimeToWait = 1.5 -- seconds before using again Distance = 10 -- distance they can use the tool from Damage = 100 --amount of hits it can withstand before it breaks DamageDone = 3 --amount of damage done to a block deb = false
function onMouse(mouse) if Damage < 1 then script.Parent.Parent:remove() end if mouse.Target ~= nil then hit = mouse.Target if deb == false and 0 < Damage then local c = game.Players[script.Parent.Parent.Parent.Name].leaderstats.Cash deb = true for i = 1,#Names do if hit.Name == Names[i] and (hit.Position - script.Parent.Parent.Parent.Torso.Position).magnitude < Distance + 1 then Damage = Damage - 1 if hit:findFirstChild"Amount" then if hit.Amount.Value > Hits[i] then c.Value = c.Value + Cash[i] hit:remove() elseif hit.Amount.Value < Hits[i] then hit.Amount.Value = hit.Amount.Value + DamageDone end elseif not hit:findFirstChild"Amount" then local h = Instance.new"IntValue" h.Parent = hit h.Name = "Amount" h.Value = 1 end end end wait(TimeToWait) deb = false end end end
script.Parent.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() onMouse(mouse) end) end)
|
|
|
| Report Abuse |
|
|