|
| 11 Jun 2013 07:45 PM |
Here is my script. It technically isn't "broken"(there are no errors in the output), but it won't function right.
By the way, this is a script that if any brick is clicked, and a certain tool is held, then it checks to see if the StringValue(child of the brick) equals R1 or R2. If so, then it proceeds to make a mining GUI for 5 seconds, and destroys it.
One more thing, I think it has something to do with the table. I just don't know what.
local tool = script.Parent -- the tool iden = {R1; R2} plr = game.Players.Player1.PlayerGui.inventory gate = false tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if mouse.target then for i, v in ipairs(iden) do if mouse.Target.ID.Value == iden[i] then
if gate == true then return end gate = true m = Instance.new("TextLabel", plr) m.Position = UDim2.new(0, 10, 0.5, 0) m.Size = UDim2.new(0, 100, 0, 40) m.BackgroundTransparency = 1 m.TextColor3 = Color3.new(1, 0, 0) m.FontSize = "Size18" m.Text = "Mining... [5]" wait(1) m.Text = "Mining... [4]" wait(1) m.Text = "Mining... [3]" wait(1) m.Text = "Mining... [2]" wait(1) m.Text = "Mining... [1]" wait(1) m:Remove() game.Workspace.iron:Remove() game.Players.Player1.PlayerGui.inventory.Frame.inventory.lglog.Visible = true gate = false end end end end) end) |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 07:57 PM |
game.Workspace.iron:Remove()
Is there more than one iron?
|
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 08:15 PM |
| Ok, scratch what I said before, sorry. I need help with the table part of the script. The GUI part and brick stuff is O.K. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 08:24 PM |
| Well, you never explained the problem. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 08:32 PM |
Edit: You never explained what's wrong with the script. Provide some more detail of what's happening and then we can help you better. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:13 PM |
Ok, here's what's happening with the script. There is no error, so Ill have to make do.
This script is a mining script. When I click a brick with a tool equipped, it(is supposed to) check if the StringValue(Called ID, child of the brick) value is in the table, iden. If it is, then it proceeds to make a GUI. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:17 PM |
Okay. I understand that.
What's wrong with it? When you click, what happens instead of what's supposed to happen? |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:20 PM |
That's the thing, nothing happens. I don't know how to be more specific now. :( |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:22 PM |
Nothing happens? In that case, I knew the answer the entire time. local tool = script.Parent -- the tool iden = {R1; R2} plr = game.Players.Player1.PlayerGui.inventory gate = false tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if mouse.target then for i, v in ipairs(iden) do if mouse.Target.ID.Value == iden[i] then gate = true---------------------------------------------I added this, that is all. if gate == true then return end gate = true m = Instance.new("TextLabel", plr) m.Position = UDim2.new(0, 10, 0.5, 0) m.Size = UDim2.new(0, 100, 0, 40) m.BackgroundTransparency = 1 m.TextColor3 = Color3.new(1, 0, 0) m.FontSize = "Size18"
m.Text = "Mining... [5]" wait(1) m.Text = "Mining... [4]" wait(1) m.Text = "Mining... [3]" wait(1) m.Text = "Mining... [2]" wait(1) m.Text = "Mining... [1]" wait(1) m:Remove() game.Workspace.iron:Remove() game.Players.Player1.PlayerGui.inventory.Frame.inventory.lglog.Visible = true gate = false end end end end) end)
I assume I fixed it, however, it may not do what you intend it to. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:23 PM |
| Nevermind I just saw a problem |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:25 PM |
| I believe that "iden = {R1; R2}" should be "iden = {R1, R2}" |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:28 PM |
Okay, I have some questions to ask: 1. Is this script a localscript? 2. game.Workspace.iron:Remove() -- Is there more than one iron in workspace?
|
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:28 PM |
It's the table parts (Iden, for i, v in ipairs) that really needs helping with.
@dog that breaks the debounce.
@unholy either works |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:30 PM |
If you think that the loop is te probelm, try replacing that line with this.
for i = 1, #iden do |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:34 PM |
In fact, you don't even need to the loop, or the table. just use this: if mouse.Target.ID.Value == "R1" or mouse.Target.ID.Value == "R2" then |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2013 09:56 PM |
local tool = script.Parent -- the tool plr = game.Players.LocalPlayer.PlayerGui.inventory--I changed the script to a localscript gate = false tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() clickd = mouse.Target print("Clicked") if mouse.Target then if mouse.Target.ID.Value == "R1" or mouse.Target.ID.Value == "R2" --then---I removed the loop and table altogether, this line is all you need if gate == true then return end gate = true m = Instance.new("TextLabel", plr) m.Position = UDim2.new(0, 10, 0.5, 0) m.Size = UDim2.new(0, 100, 0, 40) m.BackgroundTransparency = 1 m.TextColor3 = Color3.new(1, 0, 0) m.FontSize = "Size18" m.Text = "Mining... [5]" wait(1) m.Text = "Mining... [4]" wait(1) m.Text = "Mining... [3]" wait(1) m.Text = "Mining... [2]" wait(1) m.Text = "Mining... [1]" wait(1) m:Destroy() clickd:Destroy()--Destroys the brick you clicked, not iron. game.Players.Player1.PlayerGui.inventory.Frame.inventory.lglog.Visible = true gate = false end end end) end)
|
|
|
| Report Abuse |
|
|