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 » Scripting Helpers
Home Search
 

Re: Mining script help

Previous Thread :: Next Thread 
SniperOnTheRoof is not online. SniperOnTheRoof
Joined: 01 Jan 2013
Total Posts: 888
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
EpicRichGuy is not online. EpicRichGuy
Joined: 03 May 2010
Total Posts: 1533
11 Jun 2013 07:57 PM
game.Workspace.iron:Remove()

Is there more than one iron?
Report Abuse
SniperOnTheRoof is not online. SniperOnTheRoof
Joined: 01 Jan 2013
Total Posts: 888
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
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
11 Jun 2013 08:24 PM
Well, you never explained the problem.
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
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
SniperOnTheRoof is not online. SniperOnTheRoof
Joined: 01 Jan 2013
Total Posts: 888
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
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
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
SniperOnTheRoof is not online. SniperOnTheRoof
Joined: 01 Jan 2013
Total Posts: 888
11 Jun 2013 09:20 PM
That's the thing, nothing happens. I don't know how to be more specific now.
:(
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
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
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
11 Jun 2013 09:23 PM
Nevermind I just saw a problem
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
11 Jun 2013 09:25 PM
I believe that "iden = {R1; R2}" should be "iden = {R1, R2}"
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
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
SniperOnTheRoof is not online. SniperOnTheRoof
Joined: 01 Jan 2013
Total Posts: 888
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
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
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
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
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
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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