MY PICKAXE SCRIPT -- it says 21:16:01.128 - ServerScriptService.MainScript:51: attempt to index field '?' (a nil value) 21:16:01.129 - Stack Begin 21:16:01.129 - Script 'Players.Theevilem.Backpack.Pickaxe.PickaxeScript', Line 11 21:16:01.130 - Stack End
HERE IS THE CODE
local Debounce = true script.Parent.Activated:connect(function() if Debounce then Debounce = false local Ore if game:GetService("UserInputService").MouseEnabled then local Mouse = game.Players.LocalPlayer:GetMouse() Ore = Mouse.Target end if Ore and Ore.Parent == workspace.Mine then game.ReplicatedStorage.MineOre:InvokeServer(Ore) end end wait(0.3) Debounce = true end)
MY MAIN SCRIPT -- It says 21:16:01.678 - ServerScriptService.MainScript:51: attempt to index field '?' (a nil value) 21:16:01.679 - Stack Begin 21:16:01.679 - Script 'ServerScriptService.MainScript', Line 51 21:16:01.680 - Stack End
HERE IS CODE
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) repeat wait() until Character:FindFirstChild("Torso") Character.Torso.CFrame = CFrame.new(0,5050,0) end) end) local UsedPositions = {} local function PositionKey(x,y,z) return x..","..y..","..z end local function GetOreFromId(Id) for i,Ore in pairs(game.ReplicatedStorage.Ores:GetChildren()) do if Ore.Id.Value == Id then return Ore end end end local function Gamble(y) local Lottery = {} for _,Ore in pairs(game.ReplicatedStorage.Ores:GetChildren()) do local MaxDepth, MinDepth = (Ore.MaxDepth.Value > 0 and Ore.MaxDepth.Value) or 9999, (Ore.MinDepth.Value > 0 and Ore.MinDepth.Value) or 1 local Range = MaxDepth - MinDepth local MinDistance = y - MinDepth local MaxDistance = MaxDepth - y local MaxRarity, MinRarity = Ore.MaxRarity.Value, Ore.MinRarity.Value local Chance = math.ceil(((MinDistance/Range) * MinRarity + (MaxDistance/Range) * MaxRarity) / 2) for i=1,Chance do table.insert(Lottery,Ore.Id.Value) end end local Id = Lottery[math.random(1,#Lottery)] return GetOreFromId(Id) end local function GenerateOre(x,y,z) if UsedPositions[PositionKey(x,y,z)] == nil and y > 0 then local Ore = Gamble(y):Clone() Ore.Parent = workspace.Mine Ore.Position = Vector3.new(0 + x*6,5000 + y*(-6),0 + z*6) UsedPositions[PositionKey(x,y,z)] = true end end function game.ReplicatedStorage.MineOre.OnServerInvoke(Player,Ore) local CompactPos = Vector3.new(0 + Ore.Position.X/6,(Ore.Position.Y - 5000)/(-6),Ore.Position.Z/6) _G["PlayerData"][Player.Name]["Inventory"][Ore.Name] = _G["PlayerData"][Player.Name]["Inventory"][Ore.Name] + 1 game.ReplicatedStorage.InventoryChange:FireServer(Player, _G["PlayerData"][Player.Name]) for x=1,3 do for y=1,3 do for z=1,3 do if CompactPos.Y + (y-2) > 1 then GenerateOre(CompactPos.X + (x-2),CompactPos.Y + (y-2),CompactPos.Z + (z-2)) end end end end Ore:Destroy() end math.random(os.time()) for x=1,26 do for z=1,26 do GenerateOre(x,1,z) end end
THANK YOU