Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Dig tool, not working?

Asked by
viison -5
10 years ago

Hello, i have no idea what's wrong with this script. I would love if you can help me repair this script. I think it's some outdated thingy

Output:

Dig tool loaded
20:42:57.507 - Delete is not a valid member of Script
20:42:57.507 - Script 'Players.Player.Backpack.Mine.Dig', Line 10
20:42:57.507 - Stack End

EDIT:

Dig tool loaded
21:15:27.640 - Dirt is not a valid member of Player
21:15:27.641 - Script 'Players.Player.PlayerGui.Inventory.Main', Line 47
21:15:27.641 - Stack End
Clicked
Met requirements
21:15:42.916 - MineToolLvl is not a valid member of Player
21:15:42.917 - Script 'Players.Player.Backpack.Mine.Dig', Line 152 - global MouseClick
21:15:42.917 - Script 'Players.Player.Backpack.Mine.Dig', Line 182
21:15:42.917 - Stack End
21:15:42.917 - Disconnected event because of exception

The script:

wait(2)
print("Dig tool loaded")
enabled = true
exists = false
tool = script.Parent
_pos = game.Workspace["Pos"]
player = tool.Parent.Parent
gui = player:findFirstChild("PlayerGui"):findFirstChild("MineGui").Txt
deb = game.Lighting.Debris
delete_script = tool.Dig["Delete"]
error_color = script.Parent["Error"]
msg = false
digging = false
maxdist = 35


function award(plyr, type)
print("awarded!")
local numbricks = game.Players:findFirstChild(plyr).leaderstats["Bricks Dug"]
numbricks.Value = numbricks.Value + 1
local value = game.Players:findFirstChild(plyr)[type]
local maxval = game.Players:findFirstChild(plyr)["MaxAmnt"]
if value.Value < maxval.Value then
value.Value = value.Value + 1
else
value.Value = value.Value + 0
end
end


function probability(part)
part.Dug.Value = false

num = math.random(1,95)
print(num)
if num >= 1 and num <= 70 then
part.BrickColor = BrickColor.new(192)
part.Material = 816
part.Type.Value = "Dirt"
elseif num > 70 and num <= 77 then
part.BrickColor = BrickColor.new(1014)
part.Material = 1072
part.Type.Value = "Copper"
elseif num > 77 and num <= 83 then
part.BrickColor = BrickColor.new(194)
part.Material = 1072
part.Type.Value = "Silver"
elseif num > 83 and num <= 87 then
part.BrickColor = BrickColor.new(37)
part.Material = 1536
part.Type.Value = "Emerald"
elseif num > 87 and num <= 91 then
part.BrickColor = BrickColor.new(21)
part.Material = 1536
part.Type.Value = "Ruby"
elseif num > 91 and num <= 93 then
part.BrickColor = BrickColor.new(23)
part.Material = 1536
part.Type.Value = "Sapphire"
elseif num > 93 and num <= 95 then
part.BrickColor = BrickColor.new(24)
part.Material = 1072
part.Type.Value = "Gold"
end
end


function debris(type, part)
print(type)
if type == "Dirt" then
for i = 1, 3 do
local deb_clone = deb:clone()
local del_clone = delete_script:clone()
deb_clone.Parent = game.Workspace
deb_clone.CFrame = part.CFrame
deb.Velocity = Vector3.new(math.random(-10,10),0,math.random(-10,10))
del_clone.Parent = deb_clone
del_clone.Disabled = false
end
else
print("Cannot clone")
end
end


function create(part, pos)
x = part.Position.x
y = part.Position.y
z = part.Position.z
partclone = part:clone()
print("Cloned")
partclone.Name = x + pos.x .. ", " .. y + pos.y .. ", " .. z + pos.z
local check = game.Workspace.Mine:findFirstChild(partclone.Name)
local check2 = _pos:findFirstChild(partclone.Name)
local check3 = _pos:findFirstChild(part.Position.x .. ", " .. part.Position.y .. ", " .. part.Position.z)
if not check and not check2 and pos.y + y <= 8000 then
print("Check 1")
local dug_pos = Instance.new("StringValue")
dug_pos.Parent = _pos
dug_pos.Name = part.Position.x .. ", " .. part.Position.y .. ", " .. part.Position.z
if check3 then dug_pos:remove() end
probability(partclone)
partclone.Parent = game.Workspace.Mine
partclone.CFrame = CFrame.new(pos.x + x, pos.y + y, pos.z + z)
print("Part Loaded")
else
partclone:remove()
print("Deleted")
end
end


function dig(part)
if not enabled then return end
enabled = false
award(player.Name, part.Type.Value)
create(part, Vector3.new(0,-8,0))
create(part, Vector3.new(0,8,0))
create(part, Vector3.new(-8,0,0))
create(part, Vector3.new(8,0,0))
create(part, Vector3.new(0,0,-8))
create(part, Vector3.new(0,0,8))
debris(part.Type.Value, part)
part:remove()
enabled = true
end


function MouseClick(mouse)
    print("Clicked")
    if digging then return end
    if mouse.Target ~= nil then
    obj = mouse.Target
    dist = (player.Character.Torso.Position - obj.Position).magnitude
    if obj ~= nil and obj.Parent == game.Workspace.Mine and obj:findFirstChild("Dug") and not obj.Dug.Value and not msg then
        if dist > maxdist then
        msg = true
        gui.TextColor3 = error_color.Value
        gui.BorderColor3 = error_color.Value
        gui.Text = "You are too far away! Get closer!"
        wait(2)
        msg = false
        gui.Text = ""
        elseif dist <= maxdist then
        print("Met requirements")
        msg = true
        digging = true
        obj.Dug.Value = true
        gui.TextColor3 = obj.BrickColor.Color
        gui.BorderColor3 = obj.BrickColor.Color
            for i = 1,10 do
            gui.Text = "Mining " .. obj.Type.Value .. "   " .. tostring(i*10) .. "%"
            wait(player.MineToolLvl.Value / 10)
            end
        gui.TextColor3 = Color3.new(0,0,0)
        gui.BorderColor3 = Color3.new(0,0,0)
        gui.Text = ""
        msg = false
        dig(obj)
        digging = false
        end
        end
    end
end


function MouseMoved(targ)
if msg then return end
if targ and targ:findFirstChild("Type") then
gui.Text = targ.Type.Value
gui.TextColor3 = targ.BrickColor.Color
gui.BorderColor3 = targ.BrickColor.Color
elseif not targ or not targ:findFirstChild("Type") then
gui.Text = ""
gui.TextColor3 = Color3.new(0,0,0)
gui.BorderColor3 = Color3.new(0,0,0)
end
end


function Selected(mouse)
    gui.Visible = true
    mouse.Button1Down:connect(function() MouseClick(mouse) end)
    mouse.Move:connect(function() MouseMoved(mouse.Target) end)
end


function Deselected(mouse)
    gui.Visible = false
end


tool.Selected:connect(Selected)
tool.Deselected:connect(Deselected)

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Well if Delete is not a valid member of script, then obviously

delete_script = tool.Dig["Delete"]
--or, (they're the same)
delete_script = tool.Dig.Delete

is nil. There is nothing named 'Delete' inside of your script.

0
Yeah but in my "dig" script i have one more script called "Delete" that have the code: wait(2) script.Parent:remove() viison -5 — 10y
0
Well if you remove them they will obviously be nil. Perci1 4988 — 10y
0
I got a other error, i added a new output viison -5 — 10y
0
Well I think your line numbers are messed up, so I don't know where the problem is. If you get an error in the form of, 'x is not a valid member of y' then that just means x does not exist. (or at least does not exist as a child of y.) Perci1 4988 — 10y
Ad

Answer this question